﻿using System;
using System.Collections.Generic;
using System.Data;

//namespace EPP
//{
/// <summary>
/// DBCommands
/// <example>This example shows how to use DBCommands:
/// <code>
/// <newpara/>
/// DBCommands db = new DBCommands(connection_string);
/// <newpara/>
/// </code>
/// </example>
/// </summary>
public partial class DBCommands2 : MyLib.DAL_MSSQL
{
    public DBCommands2(string connectString) : base(connectString) { }

    /// <summary>
    /// DBCommands
    /// <example>This example shows how to use transaction:
    /// <code>
    /// <newpara/>
    /// try
    /// {
    ///    Common.db2.ExecSqlCmd(@"update t1 set name = @name where id = @id", name, id1);
    ///    Common.db2.ExecSqlCmd(......);
    /// }
    /// catch (Exception ex)
    /// {
    ///    log4net.Log.Error(ex);
    ///    MessageBox.Show(ex.ExceptionInfo());
    /// }
    /// 
    /// try
    /// {
    ///    Common.db2.BeginTransaction();
    ///    Common.db2.ExecSqlCmd(@"update t1 set name = @name where id = @id", name, id1);
    ///    Common.db2.ExecSqlCmd(......);
    ///    Common.db2.Commit();
    /// }
    /// catch (Prompt prompt)
    /// {
    ///    log4net.Log.Error(prompt.Message);
    ///    Common.db2.Rollback();
    ///    MessageBox.Show(prompt.ExceptionInfo());
    /// }
    /// catch (Exception ex)
    /// {
    ///    log4net.Log.Error(ex);
    ///    Common.db2.Rollback();
    ///    MessageBox.Show(ex.ExceptionInfo());
    /// }
    /// 
    /// <newpara/>
    /// </code>
    /// </example>
    /// </summary>

    #region AttachmentsInChangeRequest
    //**********************************************************
    //  AttachmentsInChangeRequest
    //**********************************************************
    CMD_AttachmentsInChangeRequest m_AttachmentsInChangeRequest = null;
    public CMD_AttachmentsInChangeRequest AttachmentsInChangeRequest
    {
        get
        {
            if (m_AttachmentsInChangeRequest == null)
                m_AttachmentsInChangeRequest = new CMD_AttachmentsInChangeRequest(this);
            return m_AttachmentsInChangeRequest;
        }
    }

    [Serializable]
    public class TBL_AttachmentsInChangeRequest
    {
        public long ID { get; set; }
        public long ChangeRequestID { get; set; }
        public long ChangeRequestRole { get; set; }
        public string AttachmentName { get; set; }
        public byte[] AttachmentDetails { get; set; }
        public long CreatedBy { get; set; }
        public DateTime CreatedDatetime { get; set; }
        public string AttachmentContentType { get; set; }

        public TBL_AttachmentsInChangeRequest()
        {
            this.ID = 0;
            this.ChangeRequestID = 0;
            this.ChangeRequestRole = 0;
            this.AttachmentName = "";
            this.AttachmentDetails = new byte[0];
            this.CreatedBy = 0;
            this.CreatedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
            this.AttachmentContentType = "";
        }

        public TBL_AttachmentsInChangeRequest(long ID, long ChangeRequestID, long ChangeRequestRole, string AttachmentName, byte[] AttachmentDetails, long CreatedBy, DateTime CreatedDatetime, string AttachmentContentType)
        {
            this.ID = ID;
            this.ChangeRequestID = ChangeRequestID;
            this.ChangeRequestRole = ChangeRequestRole;
            this.AttachmentName = AttachmentName;
            this.AttachmentDetails = AttachmentDetails;
            this.CreatedBy = CreatedBy;
            this.CreatedDatetime = CreatedDatetime;
            this.AttachmentContentType = AttachmentContentType;
        }

        public void CopyTo(ref TBL_AttachmentsInChangeRequest to)
        {
            to.ID = this.ID;
            to.ChangeRequestID = this.ChangeRequestID;
            to.ChangeRequestRole = this.ChangeRequestRole;
            to.AttachmentName = this.AttachmentName;
            to.AttachmentDetails = this.AttachmentDetails;
            to.CreatedBy = this.CreatedBy;
            to.CreatedDatetime = this.CreatedDatetime;
            to.AttachmentContentType = this.AttachmentContentType;
        }

        public bool IsSame(TBL_AttachmentsInChangeRequest x)
        {
            return (
                this.ID == x.ID &&
                this.ChangeRequestID == x.ChangeRequestID &&
                this.ChangeRequestRole == x.ChangeRequestRole &&
                this.AttachmentName == x.AttachmentName &&
                this.AttachmentDetails == x.AttachmentDetails &&
                this.CreatedBy == x.CreatedBy &&
                this.CreatedDatetime == x.CreatedDatetime &&
                this.AttachmentContentType == x.AttachmentContentType
            );
        }

        public static TBL_AttachmentsInChangeRequest ReadRow(DataRow row)
        {
            TBL_AttachmentsInChangeRequest record = new TBL_AttachmentsInChangeRequest();
            record.ID = get_long_value(row["ID"]);
            record.ChangeRequestID = get_long_value(row["ChangeRequestID"]);
            record.ChangeRequestRole = get_long_value(row["ChangeRequestRole"]);
            record.AttachmentName = get_string_value(row["AttachmentName"]);
            record.AttachmentDetails = get_bytes_value(row["AttachmentDetails"]);
            record.CreatedBy = get_long_value(row["CreatedBy"]);
            record.CreatedDatetime = get_DateTime_value(row["CreatedDatetime"]);
            record.AttachmentContentType = get_string_value(row["AttachmentContentType"]);
            return record;
        }

        public static List<TBL_AttachmentsInChangeRequest> ReadTable(DataTable dt)
        {
            List<TBL_AttachmentsInChangeRequest> records = new List<TBL_AttachmentsInChangeRequest>();
            foreach (DataRow row in dt.Rows)
                records.Add(ReadRow(row));
            return records;
        }
    }

    public class CMD_AttachmentsInChangeRequest
    {
        private MyLib.DAL_MSSQL m_db = null;

        public CMD_AttachmentsInChangeRequest(MyLib.DAL_MSSQL db)
        {
            m_db = db;
        }

        public DataTable select(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select ID, ChangeRequestID, ChangeRequestRole, AttachmentName, AttachmentDetails, CreatedBy, CreatedDatetime, AttachmentContentType
					from AttachmentsInChangeRequest
					" + where_clause, inputs);
        }

        public DataTable select()
        {
            return select("");
        }

        public DataTable selectPK(long ID)
        {
            return select(@"where ID=@ID"
                , ID);
        }

        public TBL_AttachmentsInChangeRequest select2(string where_clause, params object[] inputs)
        {
            DataTable dt = select(where_clause, inputs);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_AttachmentsInChangeRequest.ReadRow(dt.Rows[0]);
        }

        public TBL_AttachmentsInChangeRequest selectPK2(long ID)
        {
            DataTable dt = selectPK(ID);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_AttachmentsInChangeRequest.ReadRow(dt.Rows[0]);
        }

        public DataTable select_join(long ID)
        {
            return select_join("where AttachmentsInChangeRequest.ID=@ID", ID);
        }

        public DataTable select_join()
        {
            return select_join("");
        }

        public DataTable select_join(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select AttachmentsInChangeRequest.ID, AttachmentsInChangeRequest.ChangeRequestID, AttachmentsInChangeRequest.ChangeRequestRole, AttachmentsInChangeRequest.AttachmentName, AttachmentsInChangeRequest.AttachmentDetails, AttachmentsInChangeRequest.CreatedBy, AttachmentsInChangeRequest.CreatedDatetime, AttachmentsInChangeRequest.AttachmentContentType
					from AttachmentsInChangeRequest
					" + where_clause, inputs);
        }

        public void insert
        (
            ref long? ID,
            long? ChangeRequestID,
            long? ChangeRequestRole,
            string AttachmentName,
            byte[] AttachmentDetails,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            string AttachmentContentType
        )
        {

            m_db.Exec(@"
					insert into AttachmentsInChangeRequest(
						ChangeRequestID,
						ChangeRequestRole,
						AttachmentName,
						AttachmentDetails,
						CreatedBy,
						CreatedDatetime,
						AttachmentContentType
						)
					values(
						@ChangeRequestID,
						@ChangeRequestRole,
						@AttachmentName,
						@AttachmentDetails,
						@CreatedBy,
						@CreatedDatetime,
						@AttachmentContentType
						)
					", ChangeRequestID, ChangeRequestRole, AttachmentName, AttachmentDetails, CreatedBy, CreatedDatetime, AttachmentContentType);

            ID = m_db.SelectInt("select IDENT_CURRENT('AttachmentsInChangeRequest')");
        }

        public void insert
        (
            long? ChangeRequestID,
            long? ChangeRequestRole,
            string AttachmentName,
            byte[] AttachmentDetails,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            string AttachmentContentType
        )
        {
            m_db.Exec(@"
					insert into AttachmentsInChangeRequest(
						ChangeRequestID,
						ChangeRequestRole,
						AttachmentName,
						AttachmentDetails,
						CreatedBy,
						CreatedDatetime,
						AttachmentContentType
						)
					values(
						@ChangeRequestID,
						@ChangeRequestRole,
						@AttachmentName,
						@AttachmentDetails,
						@CreatedBy,
						@CreatedDatetime,
						@AttachmentContentType
						)
					", ChangeRequestID, ChangeRequestRole, AttachmentName, AttachmentDetails, CreatedBy, CreatedDatetime, AttachmentContentType);
        }

        public void update
        (
            long ID,
            long? ChangeRequestID,
            long? ChangeRequestRole,
            string AttachmentName,
            byte[] AttachmentDetails,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            string AttachmentContentType
        )
        {
            int count = m_db.SelectCount(@"select * from AttachmentsInChangeRequest where ID=@ID", ID);
            if (count == 0)
                throw new Exception("AttachmentsInChangeRequest.update error. ID does not exists");

            m_db.Exec(@"
					update AttachmentsInChangeRequest
					set
						ChangeRequestID = @ChangeRequestID,
						ChangeRequestRole = @ChangeRequestRole,
						AttachmentName = @AttachmentName,
						AttachmentDetails = @AttachmentDetails,
						CreatedBy = @CreatedBy,
						CreatedDatetime = @CreatedDatetime,
						AttachmentContentType = @AttachmentContentType
					where ID=@ID
					",
                ChangeRequestID,
                ChangeRequestRole,
                AttachmentName,
                AttachmentDetails,
                CreatedBy,
                CreatedDatetime,
                AttachmentContentType,
                ID
            );
        }

        public void delete(long ID)
        {
            int count = m_db.SelectCount(@"select * from AttachmentsInChangeRequest where ID=@ID", ID);
            if (count == 0)
                throw new Exception("AttachmentsInChangeRequest.delete error. ID does not exists");

            m_db.Exec(@"delete from AttachmentsInChangeRequest where ID=@ID", ID);
        }

    }

    #endregion

    #region AttachmentsInNotice
    //**********************************************************
    //  AttachmentsInNotice
    //**********************************************************
    CMD_AttachmentsInNotice m_AttachmentsInNotice = null;
    public CMD_AttachmentsInNotice AttachmentsInNotice
    {
        get
        {
            if (m_AttachmentsInNotice == null)
                m_AttachmentsInNotice = new CMD_AttachmentsInNotice(this);
            return m_AttachmentsInNotice;
        }
    }

    [Serializable]
    public class TBL_AttachmentsInNotice
    {
        public long ID { get; set; }
        public long NoticeID { get; set; }
        public byte[] AttachmentDetails { get; set; }
        public string AttachmentName { get; set; }
        public long CreatedBy { get; set; }
        public DateTime CreatedDatetime { get; set; }
        public long ModifiedBy { get; set; }
        public DateTime ModifiedDatetime { get; set; }
        public string AttachmentContentType { get; set; }

        public TBL_AttachmentsInNotice()
        {
            this.ID = 0;
            this.NoticeID = 0;
            this.AttachmentDetails = new byte[0];
            this.AttachmentName = "";
            this.CreatedBy = 0;
            this.CreatedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
            this.ModifiedBy = 0;
            this.ModifiedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
            this.AttachmentContentType = "";
        }

        public TBL_AttachmentsInNotice(long ID, long NoticeID, byte[] AttachmentDetails, string AttachmentName, long CreatedBy, DateTime CreatedDatetime, long ModifiedBy, DateTime ModifiedDatetime, string AttachmentContentType)
        {
            this.ID = ID;
            this.NoticeID = NoticeID;
            this.AttachmentDetails = AttachmentDetails;
            this.AttachmentName = AttachmentName;
            this.CreatedBy = CreatedBy;
            this.CreatedDatetime = CreatedDatetime;
            this.ModifiedBy = ModifiedBy;
            this.ModifiedDatetime = ModifiedDatetime;
            this.AttachmentContentType = AttachmentContentType;
        }

        public void CopyTo(ref TBL_AttachmentsInNotice to)
        {
            to.ID = this.ID;
            to.NoticeID = this.NoticeID;
            to.AttachmentDetails = this.AttachmentDetails;
            to.AttachmentName = this.AttachmentName;
            to.CreatedBy = this.CreatedBy;
            to.CreatedDatetime = this.CreatedDatetime;
            to.ModifiedBy = this.ModifiedBy;
            to.ModifiedDatetime = this.ModifiedDatetime;
            to.AttachmentContentType = this.AttachmentContentType;
        }

        public bool IsSame(TBL_AttachmentsInNotice x)
        {
            return (
                this.ID == x.ID &&
                this.NoticeID == x.NoticeID &&
                this.AttachmentDetails == x.AttachmentDetails &&
                this.AttachmentName == x.AttachmentName &&
                this.CreatedBy == x.CreatedBy &&
                this.CreatedDatetime == x.CreatedDatetime &&
                this.ModifiedBy == x.ModifiedBy &&
                this.ModifiedDatetime == x.ModifiedDatetime &&
                this.AttachmentContentType == x.AttachmentContentType
            );
        }

        public static TBL_AttachmentsInNotice ReadRow(DataRow row)
        {
            TBL_AttachmentsInNotice record = new TBL_AttachmentsInNotice();
            record.ID = get_long_value(row["ID"]);
            record.NoticeID = get_long_value(row["NoticeID"]);
            record.AttachmentDetails = get_bytes_value(row["AttachmentDetails"]);
            record.AttachmentName = get_string_value(row["AttachmentName"]);
            record.CreatedBy = get_long_value(row["CreatedBy"]);
            record.CreatedDatetime = get_DateTime_value(row["CreatedDatetime"]);
            record.ModifiedBy = get_long_value(row["ModifiedBy"]);
            record.ModifiedDatetime = get_DateTime_value(row["ModifiedDatetime"]);
            record.AttachmentContentType = get_string_value(row["AttachmentContentType"]);
            return record;
        }

        public static List<TBL_AttachmentsInNotice> ReadTable(DataTable dt)
        {
            List<TBL_AttachmentsInNotice> records = new List<TBL_AttachmentsInNotice>();
            foreach (DataRow row in dt.Rows)
                records.Add(ReadRow(row));
            return records;
        }
    }

    public class CMD_AttachmentsInNotice
    {
        private MyLib.DAL_MSSQL m_db = null;

        public CMD_AttachmentsInNotice(MyLib.DAL_MSSQL db)
        {
            m_db = db;
        }

        public DataTable select(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select ID, NoticeID, AttachmentDetails, AttachmentName, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDatetime, AttachmentContentType
					from AttachmentsInNotice
					" + where_clause, inputs);
        }

        public DataTable select()
        {
            return select("");
        }

        public DataTable selectPK(long ID)
        {
            return select(@"where ID=@ID"
                , ID);
        }

        public TBL_AttachmentsInNotice select2(string where_clause, params object[] inputs)
        {
            DataTable dt = select(where_clause, inputs);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_AttachmentsInNotice.ReadRow(dt.Rows[0]);
        }

        public TBL_AttachmentsInNotice selectPK2(long ID)
        {
            DataTable dt = selectPK(ID);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_AttachmentsInNotice.ReadRow(dt.Rows[0]);
        }

        public DataTable select_join(long ID)
        {
            return select_join("where AttachmentsInNotice.ID=@ID", ID);
        }

        public DataTable select_join()
        {
            return select_join("");
        }

        public DataTable select_join(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select AttachmentsInNotice.ID, AttachmentsInNotice.NoticeID, AttachmentsInNotice.AttachmentDetails, AttachmentsInNotice.AttachmentName, AttachmentsInNotice.CreatedBy, AttachmentsInNotice.CreatedDatetime, AttachmentsInNotice.ModifiedBy, AttachmentsInNotice.ModifiedDatetime, AttachmentsInNotice.AttachmentContentType
					from AttachmentsInNotice
					" + where_clause, inputs);
        }

        public void insert
        (
            ref long? ID,
            long? NoticeID,
            byte[] AttachmentDetails,
            string AttachmentName,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDatetime,
            string AttachmentContentType
        )
        {

            m_db.Exec(@"
					insert into AttachmentsInNotice(
						NoticeID,
						AttachmentDetails,
						AttachmentName,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDatetime,
						AttachmentContentType
						)
					values(
						@NoticeID,
						@AttachmentDetails,
						@AttachmentName,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDatetime,
						@AttachmentContentType
						)
					", NoticeID, AttachmentDetails, AttachmentName, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDatetime, AttachmentContentType);

            ID = m_db.SelectInt("select IDENT_CURRENT('AttachmentsInNotice')");
        }

        public void insert
        (
            long? NoticeID,
            byte[] AttachmentDetails,
            string AttachmentName,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDatetime,
            string AttachmentContentType
        )
        {
            m_db.Exec(@"
					insert into AttachmentsInNotice(
						NoticeID,
						AttachmentDetails,
						AttachmentName,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDatetime,
						AttachmentContentType
						)
					values(
						@NoticeID,
						@AttachmentDetails,
						@AttachmentName,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDatetime,
						@AttachmentContentType
						)
					", NoticeID, AttachmentDetails, AttachmentName, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDatetime, AttachmentContentType);
        }

        public void update
        (
            long ID,
            long? NoticeID,
            byte[] AttachmentDetails,
            string AttachmentName,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDatetime,
            string AttachmentContentType
        )
        {
            int count = m_db.SelectCount(@"select * from AttachmentsInNotice where ID=@ID", ID);
            if (count == 0)
                throw new Exception("AttachmentsInNotice.update error. ID does not exists");

            m_db.Exec(@"
					update AttachmentsInNotice
					set
						NoticeID = @NoticeID,
						AttachmentDetails = @AttachmentDetails,
						AttachmentName = @AttachmentName,
						CreatedBy = @CreatedBy,
						CreatedDatetime = @CreatedDatetime,
						ModifiedBy = @ModifiedBy,
						ModifiedDatetime = @ModifiedDatetime,
						AttachmentContentType = @AttachmentContentType
					where ID=@ID
					",
                NoticeID,
                AttachmentDetails,
                AttachmentName,
                CreatedBy,
                CreatedDatetime,
                ModifiedBy,
                ModifiedDatetime,
                AttachmentContentType,
                ID
            );
        }

        public void delete(long ID)
        {
            int count = m_db.SelectCount(@"select * from AttachmentsInNotice where ID=@ID", ID);
            if (count == 0)
                throw new Exception("AttachmentsInNotice.delete error. ID does not exists");

            m_db.Exec(@"delete from AttachmentsInNotice where ID=@ID", ID);
        }

    }

    #endregion

    #region AuditTrail
    //**********************************************************
    //  AuditTrail
    //**********************************************************
    CMD_AuditTrail m_AuditTrail = null;
    public CMD_AuditTrail AuditTrail
    {
        get
        {
            if (m_AuditTrail == null)
                m_AuditTrail = new CMD_AuditTrail(this);
            return m_AuditTrail;
        }
    }

    [Serializable]
    public class TBL_AuditTrail
    {
        public int Id { get; set; }
        public DateTime DateTime { get; set; }
        public string Script { get; set; }
        public string User { get; set; }
        public string Action { get; set; }
        public string Table { get; set; }
        public string Field { get; set; }
        public string KeyValue { get; set; }
        public string OldValue { get; set; }
        public string NewValue { get; set; }

        public TBL_AuditTrail()
        {
            this.Id = 0;
            this.DateTime = Convert.ToDateTime("1900-01-01 00:00:00");
            this.Script = "";
            this.User = "";
            this.Action = "";
            this.Table = "";
            this.Field = "";
            this.KeyValue = "";
            this.OldValue = "";
            this.NewValue = "";
        }

        public TBL_AuditTrail(int Id, DateTime DateTime, string Script, string User, string Action, string Table, string Field, string KeyValue, string OldValue, string NewValue)
        {
            this.Id = Id;
            this.DateTime = DateTime;
            this.Script = Script;
            this.User = User;
            this.Action = Action;
            this.Table = Table;
            this.Field = Field;
            this.KeyValue = KeyValue;
            this.OldValue = OldValue;
            this.NewValue = NewValue;
        }

        public void CopyTo(ref TBL_AuditTrail to)
        {
            to.Id = this.Id;
            to.DateTime = this.DateTime;
            to.Script = this.Script;
            to.User = this.User;
            to.Action = this.Action;
            to.Table = this.Table;
            to.Field = this.Field;
            to.KeyValue = this.KeyValue;
            to.OldValue = this.OldValue;
            to.NewValue = this.NewValue;
        }

        public bool IsSame(TBL_AuditTrail x)
        {
            return (
                this.Id == x.Id &&
                this.DateTime == x.DateTime &&
                this.Script == x.Script &&
                this.User == x.User &&
                this.Action == x.Action &&
                this.Table == x.Table &&
                this.Field == x.Field &&
                this.KeyValue == x.KeyValue &&
                this.OldValue == x.OldValue &&
                this.NewValue == x.NewValue
            );
        }

        public static TBL_AuditTrail ReadRow(DataRow row)
        {
            TBL_AuditTrail record = new TBL_AuditTrail();
            record.Id = get_int_value(row["Id"]);
            record.DateTime = get_DateTime_value(row["DateTime"]);
            record.Script = get_string_value(row["Script"]);
            record.User = get_string_value(row["User"]);
            record.Action = get_string_value(row["Action"]);
            record.Table = get_string_value(row["Table"]);
            record.Field = get_string_value(row["Field"]);
            record.KeyValue = get_string_value(row["KeyValue"]);
            record.OldValue = get_string_value(row["OldValue"]);
            record.NewValue = get_string_value(row["NewValue"]);
            return record;
        }

        public static List<TBL_AuditTrail> ReadTable(DataTable dt)
        {
            List<TBL_AuditTrail> records = new List<TBL_AuditTrail>();
            foreach (DataRow row in dt.Rows)
                records.Add(ReadRow(row));
            return records;
        }
    }

    public class CMD_AuditTrail
    {
        private MyLib.DAL_MSSQL m_db = null;

        public CMD_AuditTrail(MyLib.DAL_MSSQL db)
        {
            m_db = db;
        }

        public DataTable select(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select Id, DateTime, Script, User, Action, Table, Field, KeyValue, OldValue, NewValue
					from AuditTrail
					" + where_clause, inputs);
        }

        public DataTable select()
        {
            return select("");
        }

        public DataTable selectPK(int Id)
        {
            return select(@"where Id=@Id"
                , Id);
        }

        public TBL_AuditTrail select2(string where_clause, params object[] inputs)
        {
            DataTable dt = select(where_clause, inputs);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_AuditTrail.ReadRow(dt.Rows[0]);
        }

        public TBL_AuditTrail selectPK2(int Id)
        {
            DataTable dt = selectPK(Id);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_AuditTrail.ReadRow(dt.Rows[0]);
        }

        public DataTable select_join(int Id)
        {
            return select_join("where AuditTrail.Id=@Id", Id);
        }

        public DataTable select_join()
        {
            return select_join("");
        }

        public DataTable select_join(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select AuditTrail.Id, AuditTrail.DateTime, AuditTrail.Script, AuditTrail.User, AuditTrail.Action, AuditTrail.Table, AuditTrail.Field, AuditTrail.KeyValue, AuditTrail.OldValue, AuditTrail.NewValue
					from AuditTrail
					" + where_clause, inputs);
        }

        public void insert
        (
            ref int? Id,
            DateTime? DateTime,
            string Script,
            string User,
            string Action,
            string Table,
            string Field,
            string KeyValue,
            string OldValue,
            string NewValue
        )
        {

            m_db.Exec(@"
					insert into AuditTrail(
						DateTime,
						Script,
						User,
						Action,
						Table,
						Field,
						KeyValue,
						OldValue,
						NewValue
						)
					values(
						@DateTime,
						@Script,
						@User,
						@Action,
						@Table,
						@Field,
						@KeyValue,
						@OldValue,
						@NewValue
						)
					", DateTime, Script, User, Action, Table, Field, KeyValue, OldValue, NewValue);

            Id = m_db.SelectInt("select IDENT_CURRENT('AuditTrail')");
        }

        public void insert
        (
            DateTime? DateTime,
            string Script,
            string User,
            string Action,
            string Table,
            string Field,
            string KeyValue,
            string OldValue,
            string NewValue
        )
        {
            m_db.Exec(@"
					insert into AuditTrail(
						DateTime,
						Script,
						User,
						Action,
						Table,
						Field,
						KeyValue,
						OldValue,
						NewValue
						)
					values(
						@DateTime,
						@Script,
						@User,
						@Action,
						@Table,
						@Field,
						@KeyValue,
						@OldValue,
						@NewValue
						)
					", DateTime, Script, User, Action, Table, Field, KeyValue, OldValue, NewValue);
        }

        public void update
        (
            int Id,
            DateTime? DateTime,
            string Script,
            string User,
            string Action,
            string Table,
            string Field,
            string KeyValue,
            string OldValue,
            string NewValue
        )
        {
            int count = m_db.SelectCount(@"select * from AuditTrail where Id=@Id", Id);
            if (count == 0)
                throw new Exception("AuditTrail.update error. ID does not exists");

            m_db.Exec(@"
					update AuditTrail
					set
						DateTime = @DateTime,
						Script = @Script,
						User = @User,
						Action = @Action,
						Table = @Table,
						Field = @Field,
						KeyValue = @KeyValue,
						OldValue = @OldValue,
						NewValue = @NewValue
					where Id=@Id
					",
                DateTime,
                Script,
                User,
                Action,
                Table,
                Field,
                KeyValue,
                OldValue,
                NewValue,
                Id
            );
        }

        public void delete(int Id)
        {
            int count = m_db.SelectCount(@"select * from AuditTrail where Id=@Id", Id);
            if (count == 0)
                throw new Exception("AuditTrail.delete error. ID does not exists");

            m_db.Exec(@"delete from AuditTrail where Id=@Id", Id);
        }

    }

    #endregion

    #region BillConfig
    //**********************************************************
    //  BillConfig
    //**********************************************************
    CMD_BillConfig m_BillConfig = null;
    public CMD_BillConfig BillConfig
    {
        get
        {
            if (m_BillConfig == null)
                m_BillConfig = new CMD_BillConfig(this);
            return m_BillConfig;
        }
    }

    [Serializable]
    public class TBL_BillConfig
    {
        public long ID { get; set; }
        public int EmailOnReleased { get; set; }
        public int EmailOnUnreleased { get; set; }
        public string ReleaseEmailSubject { get; set; }
        public string ReleaseEmailBody { get; set; }
        public string TaxCode { get; set; }
        public string ReleaseEmailCc { get; set; }
        public string ReleaseEmailBcc { get; set; }
        public string ReleaseEmailSubject_Amended { get; set; }
        public string ReleaseEmailBody_Amended { get; set; }
        public string ReleaseEmailSubject_Adjustment { get; set; }
        public string ReleaseEmailBody_Adjustment { get; set; }
        public string ReleaseEmailSubject_Adjustment_Amended { get; set; }
        public string ReleaseEmailBody_Adjustment_Amended { get; set; }

        public TBL_BillConfig()
        {
            this.ID = 0;
            this.EmailOnReleased = 0;
            this.EmailOnUnreleased = 0;
            this.ReleaseEmailSubject = "";
            this.ReleaseEmailBody = "";
            this.TaxCode = "";
            this.ReleaseEmailCc = "";
            this.ReleaseEmailBcc = "";
            this.ReleaseEmailSubject_Amended = "";
            this.ReleaseEmailBody_Amended = "";
            this.ReleaseEmailSubject_Adjustment = "";
            this.ReleaseEmailBody_Adjustment = "";
            this.ReleaseEmailSubject_Adjustment_Amended = "";
            this.ReleaseEmailBody_Adjustment_Amended = "";
        }

        public TBL_BillConfig(long ID, int EmailOnReleased, int EmailOnUnreleased, string ReleaseEmailSubject, string ReleaseEmailBody, string TaxCode, string ReleaseEmailCc, string ReleaseEmailBcc, string ReleaseEmailSubject_Amended, string ReleaseEmailBody_Amended, string ReleaseEmailSubject_Adjustment, string ReleaseEmailBody_Adjustment, string ReleaseEmailSubject_Adjustment_Amended, string ReleaseEmailBody_Adjustment_Amended)
        {
            this.ID = ID;
            this.EmailOnReleased = EmailOnReleased;
            this.EmailOnUnreleased = EmailOnUnreleased;
            this.ReleaseEmailSubject = ReleaseEmailSubject;
            this.ReleaseEmailBody = ReleaseEmailBody;
            this.TaxCode = TaxCode;
            this.ReleaseEmailCc = ReleaseEmailCc;
            this.ReleaseEmailBcc = ReleaseEmailBcc;
            this.ReleaseEmailSubject_Amended = ReleaseEmailSubject_Amended;
            this.ReleaseEmailBody_Amended = ReleaseEmailBody_Amended;
            this.ReleaseEmailSubject_Adjustment = ReleaseEmailSubject_Adjustment;
            this.ReleaseEmailBody_Adjustment = ReleaseEmailBody_Adjustment;
            this.ReleaseEmailSubject_Adjustment_Amended = ReleaseEmailSubject_Adjustment_Amended;
            this.ReleaseEmailBody_Adjustment_Amended = ReleaseEmailBody_Adjustment_Amended;
        }

        public void CopyTo(ref TBL_BillConfig to)
        {
            to.ID = this.ID;
            to.EmailOnReleased = this.EmailOnReleased;
            to.EmailOnUnreleased = this.EmailOnUnreleased;
            to.ReleaseEmailSubject = this.ReleaseEmailSubject;
            to.ReleaseEmailBody = this.ReleaseEmailBody;
            to.TaxCode = this.TaxCode;
            to.ReleaseEmailCc = this.ReleaseEmailCc;
            to.ReleaseEmailBcc = this.ReleaseEmailBcc;
            to.ReleaseEmailSubject_Amended = this.ReleaseEmailSubject_Amended;
            to.ReleaseEmailBody_Amended = this.ReleaseEmailBody_Amended;
            to.ReleaseEmailSubject_Adjustment = this.ReleaseEmailSubject_Adjustment;
            to.ReleaseEmailBody_Adjustment = this.ReleaseEmailBody_Adjustment;
            to.ReleaseEmailSubject_Adjustment_Amended = this.ReleaseEmailSubject_Adjustment_Amended;
            to.ReleaseEmailBody_Adjustment_Amended = this.ReleaseEmailBody_Adjustment_Amended;
        }

        public bool IsSame(TBL_BillConfig x)
        {
            return (
                this.ID == x.ID &&
                this.EmailOnReleased == x.EmailOnReleased &&
                this.EmailOnUnreleased == x.EmailOnUnreleased &&
                this.ReleaseEmailSubject == x.ReleaseEmailSubject &&
                this.ReleaseEmailBody == x.ReleaseEmailBody &&
                this.TaxCode == x.TaxCode &&
                this.ReleaseEmailCc == x.ReleaseEmailCc &&
                this.ReleaseEmailBcc == x.ReleaseEmailBcc &&
                this.ReleaseEmailSubject_Amended == x.ReleaseEmailSubject_Amended &&
                this.ReleaseEmailBody_Amended == x.ReleaseEmailBody_Amended &&
                this.ReleaseEmailSubject_Adjustment == x.ReleaseEmailSubject_Adjustment &&
                this.ReleaseEmailBody_Adjustment == x.ReleaseEmailBody_Adjustment &&
                this.ReleaseEmailSubject_Adjustment_Amended == x.ReleaseEmailSubject_Adjustment_Amended &&
                this.ReleaseEmailBody_Adjustment_Amended == x.ReleaseEmailBody_Adjustment_Amended
            );
        }

        public static TBL_BillConfig ReadRow(DataRow row)
        {
            TBL_BillConfig record = new TBL_BillConfig();
            record.ID = get_long_value(row["ID"]);
            record.EmailOnReleased = get_int_value(row["EmailOnReleased"]);
            record.EmailOnUnreleased = get_int_value(row["EmailOnUnreleased"]);
            record.ReleaseEmailSubject = get_string_value(row["ReleaseEmailSubject"]);
            record.ReleaseEmailBody = get_string_value(row["ReleaseEmailBody"]);
            record.TaxCode = get_string_value(row["TaxCode"]);
            record.ReleaseEmailCc = get_string_value(row["ReleaseEmailCc"]);
            record.ReleaseEmailBcc = get_string_value(row["ReleaseEmailBcc"]);
            record.ReleaseEmailSubject_Amended = get_string_value(row["ReleaseEmailSubject_Amended"]);
            record.ReleaseEmailBody_Amended = get_string_value(row["ReleaseEmailBody_Amended"]);
            record.ReleaseEmailSubject_Adjustment = get_string_value(row["ReleaseEmailSubject_Adjustment"]);
            record.ReleaseEmailBody_Adjustment = get_string_value(row["ReleaseEmailBody_Adjustment"]);
            record.ReleaseEmailSubject_Adjustment_Amended = get_string_value(row["ReleaseEmailSubject_Adjustment_Amended"]);
            record.ReleaseEmailBody_Adjustment_Amended = get_string_value(row["ReleaseEmailBody_Adjustment_Amended"]);
            return record;
        }

        public static List<TBL_BillConfig> ReadTable(DataTable dt)
        {
            List<TBL_BillConfig> records = new List<TBL_BillConfig>();
            foreach (DataRow row in dt.Rows)
                records.Add(ReadRow(row));
            return records;
        }
    }

    public class CMD_BillConfig
    {
        private MyLib.DAL_MSSQL m_db = null;

        public CMD_BillConfig(MyLib.DAL_MSSQL db)
        {
            m_db = db;
        }

        public DataTable select(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select ID, EmailOnReleased, EmailOnUnreleased, ReleaseEmailSubject, ReleaseEmailBody, TaxCode, ReleaseEmailCc, ReleaseEmailBcc, ReleaseEmailSubject_Amended, ReleaseEmailBody_Amended, ReleaseEmailSubject_Adjustment, ReleaseEmailBody_Adjustment, ReleaseEmailSubject_Adjustment_Amended, ReleaseEmailBody_Adjustment_Amended
					from BillConfig
					" + where_clause, inputs);
        }

        public DataTable select()
        {
            return select("");
        }

        public DataTable selectPK(long ID)
        {
            return select(@"where ID=@ID"
                , ID);
        }

        public TBL_BillConfig select2(string where_clause, params object[] inputs)
        {
            DataTable dt = select(where_clause, inputs);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_BillConfig.ReadRow(dt.Rows[0]);
        }

        public TBL_BillConfig selectPK2(long ID)
        {
            DataTable dt = selectPK(ID);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_BillConfig.ReadRow(dt.Rows[0]);
        }

        public DataTable select_join(long ID)
        {
            return select_join("where BillConfig.ID=@ID", ID);
        }

        public DataTable select_join(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select BillConfig.ID, BillConfig.EmailOnReleased, BillConfig.EmailOnUnreleased, BillConfig.ReleaseEmailSubject, BillConfig.ReleaseEmailBody, BillConfig.TaxCode, BillConfig.ReleaseEmailCc, BillConfig.ReleaseEmailBcc, BillConfig.ReleaseEmailSubject_Amended, BillConfig.ReleaseEmailBody_Amended, BillConfig.ReleaseEmailSubject_Adjustment, BillConfig.ReleaseEmailBody_Adjustment, BillConfig.ReleaseEmailSubject_Adjustment_Amended, BillConfig.ReleaseEmailBody_Adjustment_Amended
					from BillConfig
					" + where_clause, inputs);
        }

        public void insert
        (
            ref long? ID,
            int? EmailOnReleased,
            int? EmailOnUnreleased,
            string ReleaseEmailSubject,
            string ReleaseEmailBody,
            string TaxCode,
            string ReleaseEmailCc,
            string ReleaseEmailBcc,
            string ReleaseEmailSubject_Amended,
            string ReleaseEmailBody_Amended,
            string ReleaseEmailSubject_Adjustment,
            string ReleaseEmailBody_Adjustment,
            string ReleaseEmailSubject_Adjustment_Amended,
            string ReleaseEmailBody_Adjustment_Amended
        )
        {
            ID = m_db.SelectInt("select isnull(MAX(ID), 0) + 1 from BillConfig");

            m_db.Exec(@"
					insert into BillConfig(
						ID,
						EmailOnReleased,
						EmailOnUnreleased,
						ReleaseEmailSubject,
						ReleaseEmailBody,
						TaxCode,
						ReleaseEmailCc,
						ReleaseEmailBcc,
						ReleaseEmailSubject_Amended,
						ReleaseEmailBody_Amended,
						ReleaseEmailSubject_Adjustment,
						ReleaseEmailBody_Adjustment,
						ReleaseEmailSubject_Adjustment_Amended,
						ReleaseEmailBody_Adjustment_Amended
						)
					values(
						@ID,
						@EmailOnReleased,
						@EmailOnUnreleased,
						@ReleaseEmailSubject,
						@ReleaseEmailBody,
						@TaxCode,
						@ReleaseEmailCc,
						@ReleaseEmailBcc,
						@ReleaseEmailSubject_Amended,
						@ReleaseEmailBody_Amended,
						@ReleaseEmailSubject_Adjustment,
						@ReleaseEmailBody_Adjustment,
						@ReleaseEmailSubject_Adjustment_Amended,
						@ReleaseEmailBody_Adjustment_Amended
						)
					", ID, EmailOnReleased, EmailOnUnreleased, ReleaseEmailSubject, ReleaseEmailBody, TaxCode, ReleaseEmailCc, ReleaseEmailBcc, ReleaseEmailSubject_Amended, ReleaseEmailBody_Amended, ReleaseEmailSubject_Adjustment, ReleaseEmailBody_Adjustment, ReleaseEmailSubject_Adjustment_Amended, ReleaseEmailBody_Adjustment_Amended);

        }

        public void insert
        (
            long? ID,
            int? EmailOnReleased,
            int? EmailOnUnreleased,
            string ReleaseEmailSubject,
            string ReleaseEmailBody,
            string TaxCode,
            string ReleaseEmailCc,
            string ReleaseEmailBcc,
            string ReleaseEmailSubject_Amended,
            string ReleaseEmailBody_Amended,
            string ReleaseEmailSubject_Adjustment,
            string ReleaseEmailBody_Adjustment,
            string ReleaseEmailSubject_Adjustment_Amended,
            string ReleaseEmailBody_Adjustment_Amended
        )
        {
            int count = m_db.SelectCount(@"select * from BillConfig where ID=@ID", ID);
            if (count > 0)
                throw new Exception("BillConfig.insert error. ID duplicate");

            m_db.Exec(@"
					insert into BillConfig(
						ID,
						EmailOnReleased,
						EmailOnUnreleased,
						ReleaseEmailSubject,
						ReleaseEmailBody,
						TaxCode,
						ReleaseEmailCc,
						ReleaseEmailBcc,
						ReleaseEmailSubject_Amended,
						ReleaseEmailBody_Amended,
						ReleaseEmailSubject_Adjustment,
						ReleaseEmailBody_Adjustment,
						ReleaseEmailSubject_Adjustment_Amended,
						ReleaseEmailBody_Adjustment_Amended
						)
					values(
						@ID,
						@EmailOnReleased,
						@EmailOnUnreleased,
						@ReleaseEmailSubject,
						@ReleaseEmailBody,
						@TaxCode,
						@ReleaseEmailCc,
						@ReleaseEmailBcc,
						@ReleaseEmailSubject_Amended,
						@ReleaseEmailBody_Amended,
						@ReleaseEmailSubject_Adjustment,
						@ReleaseEmailBody_Adjustment,
						@ReleaseEmailSubject_Adjustment_Amended,
						@ReleaseEmailBody_Adjustment_Amended
						)
					", ID, EmailOnReleased, EmailOnUnreleased, ReleaseEmailSubject, ReleaseEmailBody, TaxCode, ReleaseEmailCc, ReleaseEmailBcc, ReleaseEmailSubject_Amended, ReleaseEmailBody_Amended, ReleaseEmailSubject_Adjustment, ReleaseEmailBody_Adjustment, ReleaseEmailSubject_Adjustment_Amended, ReleaseEmailBody_Adjustment_Amended);
        }

        public void update
        (
            long _old_ID,
            long _new_ID,
            int? EmailOnReleased,
            int? EmailOnUnreleased,
            string ReleaseEmailSubject,
            string ReleaseEmailBody,
            string TaxCode,
            string ReleaseEmailCc,
            string ReleaseEmailBcc,
            string ReleaseEmailSubject_Amended,
            string ReleaseEmailBody_Amended,
            string ReleaseEmailSubject_Adjustment,
            string ReleaseEmailBody_Adjustment,
            string ReleaseEmailSubject_Adjustment_Amended,
            string ReleaseEmailBody_Adjustment_Amended
        )
        {
            int count = m_db.SelectCount(@"select * from BillConfig where ID=@_old_ID", _old_ID);
            if (count == 0)
                throw new Exception("BillConfig.update error. ID does not exists");

            m_db.Exec(@"
					update BillConfig
					set
						ID = @_new_ID,
						EmailOnReleased = @EmailOnReleased,
						EmailOnUnreleased = @EmailOnUnreleased,
						ReleaseEmailSubject = @ReleaseEmailSubject,
						ReleaseEmailBody = @ReleaseEmailBody,
						TaxCode = @TaxCode,
						ReleaseEmailCc = @ReleaseEmailCc,
						ReleaseEmailBcc = @ReleaseEmailBcc,
						ReleaseEmailSubject_Amended = @ReleaseEmailSubject_Amended,
						ReleaseEmailBody_Amended = @ReleaseEmailBody_Amended,
						ReleaseEmailSubject_Adjustment = @ReleaseEmailSubject_Adjustment,
						ReleaseEmailBody_Adjustment = @ReleaseEmailBody_Adjustment,
						ReleaseEmailSubject_Adjustment_Amended = @ReleaseEmailSubject_Adjustment_Amended,
						ReleaseEmailBody_Adjustment_Amended = @ReleaseEmailBody_Adjustment_Amended
					where ID=@_old_ID
					",
                _new_ID,
                EmailOnReleased,
                EmailOnUnreleased,
                ReleaseEmailSubject,
                ReleaseEmailBody,
                TaxCode,
                ReleaseEmailCc,
                ReleaseEmailBcc,
                ReleaseEmailSubject_Amended,
                ReleaseEmailBody_Amended,
                ReleaseEmailSubject_Adjustment,
                ReleaseEmailBody_Adjustment,
                ReleaseEmailSubject_Adjustment_Amended,
                ReleaseEmailBody_Adjustment_Amended,
                _old_ID
            );
        }

        public void delete(long ID)
        {
            int count = m_db.SelectCount(@"select * from BillConfig where ID=@ID", ID);
            if (count == 0)
                throw new Exception("BillConfig.delete error. ID does not exists");

            m_db.Exec(@"delete from BillConfig where ID=@ID", ID);
        }

    }

    #endregion

    #region BillCustomer
    //**********************************************************
    //  BillCustomer
    //**********************************************************
    CMD_BillCustomer m_BillCustomer = null;
    public CMD_BillCustomer BillCustomer
    {
        get
        {
            if (m_BillCustomer == null)
                m_BillCustomer = new CMD_BillCustomer(this);
            return m_BillCustomer;
        }
    }

    [Serializable]
    public class TBL_BillCustomer
    {
        public long ID { get; set; }
        public string BillType { get; set; }
        public string CustNo { get; set; }
        public string CustName1 { get; set; }
        public string CustName2 { get; set; }
        public string BUCode { get; set; }
        public string Address { get; set; }
        public string ContactPerson { get; set; }
        public string PaymentTerm { get; set; }
        public string SpecialInstruction { get; set; }
        public string GroupBy { get; set; }
        public long SiteID { get; set; }
        public string TelNo { get; set; }
        public string FaxNo { get; set; }
        public string EmailTo { get; set; }
        public string Remarks { get; set; }
        public long CreatedBy { get; set; }
        public DateTime CreatedDatetime { get; set; }
        public long ModifiedBy { get; set; }
        public DateTime ModifiedDateTime { get; set; }

        public TBL_BillCustomer()
        {
            this.ID = 0;
            this.BillType = "";
            this.CustNo = "";
            this.CustName1 = "";
            this.CustName2 = "";
            this.BUCode = "";
            this.Address = "";
            this.ContactPerson = "";
            this.PaymentTerm = "";
            this.SpecialInstruction = "";
            this.GroupBy = "";
            this.SiteID = 0;
            this.TelNo = "";
            this.FaxNo = "";
            this.EmailTo = "";
            this.Remarks = "";
            this.CreatedBy = 0;
            this.CreatedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
            this.ModifiedBy = 0;
            this.ModifiedDateTime = Convert.ToDateTime("1900-01-01 00:00:00");
        }

        public TBL_BillCustomer(long ID, string BillType, string CustNo, string CustName1, string CustName2, string BUCode, string Address, string ContactPerson, string PaymentTerm, string SpecialInstruction, string GroupBy, long SiteID, string TelNo, string FaxNo, string EmailTo, string Remarks, long CreatedBy, DateTime CreatedDatetime, long ModifiedBy, DateTime ModifiedDateTime)
        {
            this.ID = ID;
            this.BillType = BillType;
            this.CustNo = CustNo;
            this.CustName1 = CustName1;
            this.CustName2 = CustName2;
            this.BUCode = BUCode;
            this.Address = Address;
            this.ContactPerson = ContactPerson;
            this.PaymentTerm = PaymentTerm;
            this.SpecialInstruction = SpecialInstruction;
            this.GroupBy = GroupBy;
            this.SiteID = SiteID;
            this.TelNo = TelNo;
            this.FaxNo = FaxNo;
            this.EmailTo = EmailTo;
            this.Remarks = Remarks;
            this.CreatedBy = CreatedBy;
            this.CreatedDatetime = CreatedDatetime;
            this.ModifiedBy = ModifiedBy;
            this.ModifiedDateTime = ModifiedDateTime;
        }

        public void CopyTo(ref TBL_BillCustomer to)
        {
            to.ID = this.ID;
            to.BillType = this.BillType;
            to.CustNo = this.CustNo;
            to.CustName1 = this.CustName1;
            to.CustName2 = this.CustName2;
            to.BUCode = this.BUCode;
            to.Address = this.Address;
            to.ContactPerson = this.ContactPerson;
            to.PaymentTerm = this.PaymentTerm;
            to.SpecialInstruction = this.SpecialInstruction;
            to.GroupBy = this.GroupBy;
            to.SiteID = this.SiteID;
            to.TelNo = this.TelNo;
            to.FaxNo = this.FaxNo;
            to.EmailTo = this.EmailTo;
            to.Remarks = this.Remarks;
            to.CreatedBy = this.CreatedBy;
            to.CreatedDatetime = this.CreatedDatetime;
            to.ModifiedBy = this.ModifiedBy;
            to.ModifiedDateTime = this.ModifiedDateTime;
        }

        public bool IsSame(TBL_BillCustomer x)
        {
            return (
                this.ID == x.ID &&
                this.BillType == x.BillType &&
                this.CustNo == x.CustNo &&
                this.CustName1 == x.CustName1 &&
                this.CustName2 == x.CustName2 &&
                this.BUCode == x.BUCode &&
                this.Address == x.Address &&
                this.ContactPerson == x.ContactPerson &&
                this.PaymentTerm == x.PaymentTerm &&
                this.SpecialInstruction == x.SpecialInstruction &&
                this.GroupBy == x.GroupBy &&
                this.SiteID == x.SiteID &&
                this.TelNo == x.TelNo &&
                this.FaxNo == x.FaxNo &&
                this.EmailTo == x.EmailTo &&
                this.Remarks == x.Remarks &&
                this.CreatedBy == x.CreatedBy &&
                this.CreatedDatetime == x.CreatedDatetime &&
                this.ModifiedBy == x.ModifiedBy &&
                this.ModifiedDateTime == x.ModifiedDateTime
            );
        }

        public static TBL_BillCustomer ReadRow(DataRow row)
        {
            TBL_BillCustomer record = new TBL_BillCustomer();
            record.ID = get_long_value(row["ID"]);
            record.BillType = get_string_value(row["BillType"]);
            record.CustNo = get_string_value(row["CustNo"]);
            record.CustName1 = get_string_value(row["CustName1"]);
            record.CustName2 = get_string_value(row["CustName2"]);
            record.BUCode = get_string_value(row["BUCode"]);
            record.Address = get_string_value(row["Address"]);
            record.ContactPerson = get_string_value(row["ContactPerson"]);
            record.PaymentTerm = get_string_value(row["PaymentTerm"]);
            record.SpecialInstruction = get_string_value(row["SpecialInstruction"]);
            record.GroupBy = get_string_value(row["GroupBy"]);
            record.SiteID = get_long_value(row["SiteID"]);
            record.TelNo = get_string_value(row["TelNo"]);
            record.FaxNo = get_string_value(row["FaxNo"]);
            record.EmailTo = get_string_value(row["EmailTo"]);
            record.Remarks = get_string_value(row["Remarks"]);
            record.CreatedBy = get_long_value(row["CreatedBy"]);
            record.CreatedDatetime = get_DateTime_value(row["CreatedDatetime"]);
            record.ModifiedBy = get_long_value(row["ModifiedBy"]);
            record.ModifiedDateTime = get_DateTime_value(row["ModifiedDateTime"]);
            return record;
        }

        public static List<TBL_BillCustomer> ReadTable(DataTable dt)
        {
            List<TBL_BillCustomer> records = new List<TBL_BillCustomer>();
            foreach (DataRow row in dt.Rows)
                records.Add(ReadRow(row));
            return records;
        }
    }

    public class CMD_BillCustomer
    {
        private MyLib.DAL_MSSQL m_db = null;

        public CMD_BillCustomer(MyLib.DAL_MSSQL db)
        {
            m_db = db;
        }

        public DataTable select(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select ID, BillType, CustNo, CustName1, CustName2, BUCode, Address, ContactPerson, PaymentTerm, SpecialInstruction, GroupBy, SiteID, TelNo, FaxNo, EmailTo, Remarks, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime
					from BillCustomer
					" + where_clause, inputs);
        }

        public DataTable select()
        {
            return select("");
        }

        public DataTable selectPK(long ID)
        {
            return select(@"where ID=@ID"
                , ID);
        }

        public TBL_BillCustomer select2(string where_clause, params object[] inputs)
        {
            DataTable dt = select(where_clause, inputs);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_BillCustomer.ReadRow(dt.Rows[0]);
        }

        public TBL_BillCustomer selectPK2(long ID)
        {
            DataTable dt = selectPK(ID);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_BillCustomer.ReadRow(dt.Rows[0]);
        }

        public DataTable select_join(long ID)
        {
            return select_join("where BillCustomer.ID=@ID", ID);
        }

        public DataTable select_join()
        {
            return select_join("");
        }

        public DataTable select_join(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select BillCustomer.ID, BillCustomer.BillType, BillCustomer.CustNo, BillCustomer.CustName1, BillCustomer.CustName2, BillCustomer.BUCode, BillCustomer.Address, BillCustomer.ContactPerson, BillCustomer.PaymentTerm, BillCustomer.SpecialInstruction, BillCustomer.GroupBy, BillCustomer.SiteID, BillCustomer.TelNo, BillCustomer.FaxNo, BillCustomer.EmailTo, BillCustomer.Remarks, BillCustomer.CreatedBy, BillCustomer.CreatedDatetime, BillCustomer.ModifiedBy, BillCustomer.ModifiedDateTime
					from BillCustomer
					" + where_clause, inputs);
        }

        public void insert
        (
            ref long? ID,
            string BillType,
            string CustNo,
            string CustName1,
            string CustName2,
            string BUCode,
            string Address,
            string ContactPerson,
            string PaymentTerm,
            string SpecialInstruction,
            string GroupBy,
            long? SiteID,
            string TelNo,
            string FaxNo,
            string EmailTo,
            string Remarks,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDateTime
        )
        {

            m_db.Exec(@"
					insert into BillCustomer(
						BillType,
						CustNo,
						CustName1,
						CustName2,
						BUCode,
						Address,
						ContactPerson,
						PaymentTerm,
						SpecialInstruction,
						GroupBy,
						SiteID,
						TelNo,
						FaxNo,
						EmailTo,
						Remarks,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDateTime
						)
					values(
						@BillType,
						@CustNo,
						@CustName1,
						@CustName2,
						@BUCode,
						@Address,
						@ContactPerson,
						@PaymentTerm,
						@SpecialInstruction,
						@GroupBy,
						@SiteID,
						@TelNo,
						@FaxNo,
						@EmailTo,
						@Remarks,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDateTime
						)
					", BillType, CustNo, CustName1, CustName2, BUCode, Address, ContactPerson, PaymentTerm, SpecialInstruction, GroupBy, SiteID, TelNo, FaxNo, EmailTo, Remarks, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime);

            ID = m_db.SelectInt("select IDENT_CURRENT('BillCustomer')");
        }

        public void insert
        (
            string BillType,
            string CustNo,
            string CustName1,
            string CustName2,
            string BUCode,
            string Address,
            string ContactPerson,
            string PaymentTerm,
            string SpecialInstruction,
            string GroupBy,
            long? SiteID,
            string TelNo,
            string FaxNo,
            string EmailTo,
            string Remarks,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDateTime
        )
        {
            m_db.Exec(@"
					insert into BillCustomer(
						BillType,
						CustNo,
						CustName1,
						CustName2,
						BUCode,
						Address,
						ContactPerson,
						PaymentTerm,
						SpecialInstruction,
						GroupBy,
						SiteID,
						TelNo,
						FaxNo,
						EmailTo,
						Remarks,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDateTime
						)
					values(
						@BillType,
						@CustNo,
						@CustName1,
						@CustName2,
						@BUCode,
						@Address,
						@ContactPerson,
						@PaymentTerm,
						@SpecialInstruction,
						@GroupBy,
						@SiteID,
						@TelNo,
						@FaxNo,
						@EmailTo,
						@Remarks,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDateTime
						)
					", BillType, CustNo, CustName1, CustName2, BUCode, Address, ContactPerson, PaymentTerm, SpecialInstruction, GroupBy, SiteID, TelNo, FaxNo, EmailTo, Remarks, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime);
        }

        public void update
        (
            long ID,
            string BillType,
            string CustNo,
            string CustName1,
            string CustName2,
            string BUCode,
            string Address,
            string ContactPerson,
            string PaymentTerm,
            string SpecialInstruction,
            string GroupBy,
            long? SiteID,
            string TelNo,
            string FaxNo,
            string EmailTo,
            string Remarks,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDateTime
        )
        {
            int count = m_db.SelectCount(@"select * from BillCustomer where ID=@ID", ID);
            if (count == 0)
                throw new Exception("BillCustomer.update error. ID does not exists");

            m_db.Exec(@"
					update BillCustomer
					set
						BillType = @BillType,
						CustNo = @CustNo,
						CustName1 = @CustName1,
						CustName2 = @CustName2,
						BUCode = @BUCode,
						Address = @Address,
						ContactPerson = @ContactPerson,
						PaymentTerm = @PaymentTerm,
						SpecialInstruction = @SpecialInstruction,
						GroupBy = @GroupBy,
						SiteID = @SiteID,
						TelNo = @TelNo,
						FaxNo = @FaxNo,
						EmailTo = @EmailTo,
						Remarks = @Remarks,
						CreatedBy = @CreatedBy,
						CreatedDatetime = @CreatedDatetime,
						ModifiedBy = @ModifiedBy,
						ModifiedDateTime = @ModifiedDateTime
					where ID=@ID
					",
                BillType,
                CustNo,
                CustName1,
                CustName2,
                BUCode,
                Address,
                ContactPerson,
                PaymentTerm,
                SpecialInstruction,
                GroupBy,
                SiteID,
                TelNo,
                FaxNo,
                EmailTo,
                Remarks,
                CreatedBy,
                CreatedDatetime,
                ModifiedBy,
                ModifiedDateTime,
                ID
            );
        }

        public void delete(long ID)
        {
            int count = m_db.SelectCount(@"select * from BillCustomer where ID=@ID", ID);
            if (count == 0)
                throw new Exception("BillCustomer.delete error. ID does not exists");

            m_db.Exec(@"delete from BillCustomer where ID=@ID", ID);
        }

    }

    #endregion

    #region BillCustomerCC
    //**********************************************************
    //  BillCustomerCC
    //**********************************************************
    CMD_BillCustomerCC m_BillCustomerCC = null;
    public CMD_BillCustomerCC BillCustomerCC
    {
        get
        {
            if (m_BillCustomerCC == null)
                m_BillCustomerCC = new CMD_BillCustomerCC(this);
            return m_BillCustomerCC;
        }
    }

    [Serializable]
    public class TBL_BillCustomerCC
    {
        public long ID { get; set; }
        public long BillCustomerID { get; set; }
        public long CostCentreID { get; set; }

        public TBL_BillCustomerCC()
        {
            this.ID = 0;
            this.BillCustomerID = 0;
            this.CostCentreID = 0;
        }

        public TBL_BillCustomerCC(long ID, long BillCustomerID, long CostCentreID)
        {
            this.ID = ID;
            this.BillCustomerID = BillCustomerID;
            this.CostCentreID = CostCentreID;
        }

        public void CopyTo(ref TBL_BillCustomerCC to)
        {
            to.ID = this.ID;
            to.BillCustomerID = this.BillCustomerID;
            to.CostCentreID = this.CostCentreID;
        }

        public bool IsSame(TBL_BillCustomerCC x)
        {
            return (
                this.ID == x.ID &&
                this.BillCustomerID == x.BillCustomerID &&
                this.CostCentreID == x.CostCentreID
            );
        }

        public static TBL_BillCustomerCC ReadRow(DataRow row)
        {
            TBL_BillCustomerCC record = new TBL_BillCustomerCC();
            record.ID = get_long_value(row["ID"]);
            record.BillCustomerID = get_long_value(row["BillCustomerID"]);
            record.CostCentreID = get_long_value(row["CostCentreID"]);
            return record;
        }

        public static List<TBL_BillCustomerCC> ReadTable(DataTable dt)
        {
            List<TBL_BillCustomerCC> records = new List<TBL_BillCustomerCC>();
            foreach (DataRow row in dt.Rows)
                records.Add(ReadRow(row));
            return records;
        }
    }

    public class CMD_BillCustomerCC
    {
        private MyLib.DAL_MSSQL m_db = null;

        public CMD_BillCustomerCC(MyLib.DAL_MSSQL db)
        {
            m_db = db;
        }

        public DataTable select(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select ID, BillCustomerID, CostCentreID
					from BillCustomerCC
					" + where_clause, inputs);
        }

        public DataTable select()
        {
            return select("");
        }

        public DataTable selectPK(long ID)
        {
            return select(@"where ID=@ID"
                , ID);
        }

        public TBL_BillCustomerCC select2(string where_clause, params object[] inputs)
        {
            DataTable dt = select(where_clause, inputs);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_BillCustomerCC.ReadRow(dt.Rows[0]);
        }

        public TBL_BillCustomerCC selectPK2(long ID)
        {
            DataTable dt = selectPK(ID);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_BillCustomerCC.ReadRow(dt.Rows[0]);
        }

        public DataTable select_join(long ID)
        {
            return select_join("where BillCustomerCC.ID=@ID", ID);
        }

        public DataTable select_join()
        {
            return select_join("");
        }

        public DataTable select_join(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select BillCustomerCC.ID, BillCustomerCC.BillCustomerID, BillCustomerCC.CostCentreID
					from BillCustomerCC
					" + where_clause, inputs);
        }

        public void insert
        (
            ref long? ID,
            long? BillCustomerID,
            long? CostCentreID
        )
        {

            m_db.Exec(@"
					insert into BillCustomerCC(
						BillCustomerID,
						CostCentreID
						)
					values(
						@BillCustomerID,
						@CostCentreID
						)
					", BillCustomerID, CostCentreID);

            ID = m_db.SelectInt("select IDENT_CURRENT('BillCustomerCC')");
        }

        public void insert
        (
            long? BillCustomerID,
            long? CostCentreID
        )
        {
            m_db.Exec(@"
					insert into BillCustomerCC(
						BillCustomerID,
						CostCentreID
						)
					values(
						@BillCustomerID,
						@CostCentreID
						)
					", BillCustomerID, CostCentreID);
        }

        public void update
        (
            long ID,
            long? BillCustomerID,
            long? CostCentreID
        )
        {
            int count = m_db.SelectCount(@"select * from BillCustomerCC where ID=@ID", ID);
            if (count == 0)
                throw new Exception("BillCustomerCC.update error. ID does not exists");

            m_db.Exec(@"
					update BillCustomerCC
					set
						BillCustomerID = @BillCustomerID,
						CostCentreID = @CostCentreID
					where ID=@ID
					",
                BillCustomerID,
                CostCentreID,
                ID
            );
        }

        public void delete(long ID)
        {
            int count = m_db.SelectCount(@"select * from BillCustomerCC where ID=@ID", ID);
            if (count == 0)
                throw new Exception("BillCustomerCC.delete error. ID does not exists");

            m_db.Exec(@"delete from BillCustomerCC where ID=@ID", ID);
        }

    }

    #endregion

    #region BillItem
    //**********************************************************
    //  BillItem
    //**********************************************************
    CMD_BillItem m_BillItem = null;
    public CMD_BillItem BillItem
    {
        get
        {
            if (m_BillItem == null)
                m_BillItem = new CMD_BillItem(this);
            return m_BillItem;
        }
    }

    [Serializable]
    public class TBL_BillItem
    {
        public long ID { get; set; }
        public string ItemNo { get; set; }
        public string ItemName { get; set; }

        public TBL_BillItem()
        {
            this.ID = 0;
            this.ItemNo = "";
            this.ItemName = "";
        }

        public TBL_BillItem(long ID, string ItemNo, string ItemName)
        {
            this.ID = ID;
            this.ItemNo = ItemNo;
            this.ItemName = ItemName;
        }

        public void CopyTo(ref TBL_BillItem to)
        {
            to.ID = this.ID;
            to.ItemNo = this.ItemNo;
            to.ItemName = this.ItemName;
        }

        public bool IsSame(TBL_BillItem x)
        {
            return (
                this.ID == x.ID &&
                this.ItemNo == x.ItemNo &&
                this.ItemName == x.ItemName
            );
        }

        public static TBL_BillItem ReadRow(DataRow row)
        {
            TBL_BillItem record = new TBL_BillItem();
            record.ID = get_long_value(row["ID"]);
            record.ItemNo = get_string_value(row["ItemNo"]);
            record.ItemName = get_string_value(row["ItemName"]);
            return record;
        }

        public static List<TBL_BillItem> ReadTable(DataTable dt)
        {
            List<TBL_BillItem> records = new List<TBL_BillItem>();
            foreach (DataRow row in dt.Rows)
                records.Add(ReadRow(row));
            return records;
        }
    }

    public class CMD_BillItem
    {
        private MyLib.DAL_MSSQL m_db = null;

        public CMD_BillItem(MyLib.DAL_MSSQL db)
        {
            m_db = db;
        }

        public DataTable select(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select ID, ItemNo, ItemName
					from BillItem
					" + where_clause, inputs);
        }

        public DataTable select()
        {
            return select("");
        }

        public DataTable selectPK(long ID)
        {
            return select(@"where ID=@ID"
                , ID);
        }

        public TBL_BillItem select2(string where_clause, params object[] inputs)
        {
            DataTable dt = select(where_clause, inputs);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_BillItem.ReadRow(dt.Rows[0]);
        }

        public TBL_BillItem selectPK2(long ID)
        {
            DataTable dt = selectPK(ID);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_BillItem.ReadRow(dt.Rows[0]);
        }

        public DataTable select_join(long ID)
        {
            return select_join("where BillItem.ID=@ID", ID);
        }

        public DataTable select_join()
        {
            return select_join("");
        }

        public DataTable select_join(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select BillItem.ID, BillItem.ItemNo, BillItem.ItemName
					from BillItem
					" + where_clause, inputs);
        }

        public void insert
        (
            ref long? ID,
            string ItemNo,
            string ItemName
        )
        {

            m_db.Exec(@"
					insert into BillItem(
						ItemNo,
						ItemName
						)
					values(
						@ItemNo,
						@ItemName
						)
					", ItemNo, ItemName);

            ID = m_db.SelectInt("select IDENT_CURRENT('BillItem')");
        }

        public void insert
        (
            string ItemNo,
            string ItemName
        )
        {
            m_db.Exec(@"
					insert into BillItem(
						ItemNo,
						ItemName
						)
					values(
						@ItemNo,
						@ItemName
						)
					", ItemNo, ItemName);
        }

        public void update
        (
            long ID,
            string ItemNo,
            string ItemName
        )
        {
            int count = m_db.SelectCount(@"select * from BillItem where ID=@ID", ID);
            if (count == 0)
                throw new Exception("BillItem.update error. ID does not exists");

            m_db.Exec(@"
					update BillItem
					set
						ItemNo = @ItemNo,
						ItemName = @ItemName
					where ID=@ID
					",
                ItemNo,
                ItemName,
                ID
            );
        }

        public void delete(long ID)
        {
            int count = m_db.SelectCount(@"select * from BillItem where ID=@ID", ID);
            if (count == 0)
                throw new Exception("BillItem.delete error. ID does not exists");

            m_db.Exec(@"delete from BillItem where ID=@ID", ID);
        }

    }

    #endregion

    #region BillMonthly
    //**********************************************************
    //  BillMonthly
    //**********************************************************
    CMD_BillMonthly m_BillMonthly = null;
    public CMD_BillMonthly BillMonthly
    {
        get
        {
            if (m_BillMonthly == null)
                m_BillMonthly = new CMD_BillMonthly(this);
            return m_BillMonthly;
        }
    }

    [Serializable]
    public class TBL_BillMonthly
    {
        public long ID { get; set; }
        public long BillPeriodID { get; set; }
        public long ServiceFormID { get; set; }
        public long OrgID { get; set; }
        public long SiteID { get; set; }
        public long CostCentreID { get; set; }
        public string Email { get; set; }
        public DateTime EffectiveDate { get; set; }
        public DateTime TerminatedDate { get; set; }
        public decimal UnitPrice { get; set; }
        public decimal OneTimeCharge { get; set; }
        public string Remarks { get; set; }
        public string AssetID { get; set; }
        public string Username { get; set; }

        public TBL_BillMonthly()
        {
            this.ID = 0;
            this.BillPeriodID = 0;
            this.ServiceFormID = 0;
            this.OrgID = 0;
            this.SiteID = 0;
            this.CostCentreID = 0;
            this.Email = "";
            this.EffectiveDate = Convert.ToDateTime("1900-01-01 00:00:00");
            this.TerminatedDate = Convert.ToDateTime("1900-01-01 00:00:00");
            this.UnitPrice = 0M;
            this.OneTimeCharge = 0M;
            this.Remarks = "";
            this.AssetID = "";
            this.Username = "";
        }

        public TBL_BillMonthly(long ID, long BillPeriodID, long ServiceFormID, long OrgID, long SiteID, long CostCentreID, string Email, DateTime EffectiveDate, DateTime TerminatedDate, decimal UnitPrice, decimal OneTimeCharge, string Remarks, string AssetID, string Username)
        {
            this.ID = ID;
            this.BillPeriodID = BillPeriodID;
            this.ServiceFormID = ServiceFormID;
            this.OrgID = OrgID;
            this.SiteID = SiteID;
            this.CostCentreID = CostCentreID;
            this.Email = Email;
            this.EffectiveDate = EffectiveDate;
            this.TerminatedDate = TerminatedDate;
            this.UnitPrice = UnitPrice;
            this.OneTimeCharge = OneTimeCharge;
            this.Remarks = Remarks;
            this.AssetID = AssetID;
            this.Username = Username;
        }

        public void CopyTo(ref TBL_BillMonthly to)
        {
            to.ID = this.ID;
            to.BillPeriodID = this.BillPeriodID;
            to.ServiceFormID = this.ServiceFormID;
            to.OrgID = this.OrgID;
            to.SiteID = this.SiteID;
            to.CostCentreID = this.CostCentreID;
            to.Email = this.Email;
            to.EffectiveDate = this.EffectiveDate;
            to.TerminatedDate = this.TerminatedDate;
            to.UnitPrice = this.UnitPrice;
            to.OneTimeCharge = this.OneTimeCharge;
            to.Remarks = this.Remarks;
            to.AssetID = this.AssetID;
            to.Username = this.Username;
        }

        public bool IsSame(TBL_BillMonthly x)
        {
            return (
                this.ID == x.ID &&
                this.BillPeriodID == x.BillPeriodID &&
                this.ServiceFormID == x.ServiceFormID &&
                this.OrgID == x.OrgID &&
                this.SiteID == x.SiteID &&
                this.CostCentreID == x.CostCentreID &&
                this.Email == x.Email &&
                this.EffectiveDate == x.EffectiveDate &&
                this.TerminatedDate == x.TerminatedDate &&
                this.UnitPrice == x.UnitPrice &&
                this.OneTimeCharge == x.OneTimeCharge &&
                this.Remarks == x.Remarks &&
                this.AssetID == x.AssetID &&
                this.Username == x.Username
            );
        }

        public static TBL_BillMonthly ReadRow(DataRow row)
        {
            TBL_BillMonthly record = new TBL_BillMonthly();
            record.ID = get_long_value(row["ID"]);
            record.BillPeriodID = get_long_value(row["BillPeriodID"]);
            record.ServiceFormID = get_long_value(row["ServiceFormID"]);
            record.OrgID = get_long_value(row["OrgID"]);
            record.SiteID = get_long_value(row["SiteID"]);
            record.CostCentreID = get_long_value(row["CostCentreID"]);
            record.Email = get_string_value(row["Email"]);
            record.EffectiveDate = get_DateTime_value(row["EffectiveDate"]);
            record.TerminatedDate = get_DateTime_value(row["TerminatedDate"]);
            record.UnitPrice = get_decimal_value(row["UnitPrice"]);
            record.OneTimeCharge = get_decimal_value(row["OneTimeCharge"]);
            record.Remarks = get_string_value(row["Remarks"]);
            record.AssetID = get_string_value(row["AssetID"]);
            record.Username = get_string_value(row["Username"]);
            return record;
        }

        public static List<TBL_BillMonthly> ReadTable(DataTable dt)
        {
            List<TBL_BillMonthly> records = new List<TBL_BillMonthly>();
            foreach (DataRow row in dt.Rows)
                records.Add(ReadRow(row));
            return records;
        }
    }

    public class CMD_BillMonthly
    {
        private MyLib.DAL_MSSQL m_db = null;

        public CMD_BillMonthly(MyLib.DAL_MSSQL db)
        {
            m_db = db;
        }

        public DataTable select(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select ID, BillPeriodID, ServiceFormID, OrgID, SiteID, CostCentreID, Email, EffectiveDate, TerminatedDate, UnitPrice, OneTimeCharge, Remarks, AssetID, Username
					from BillMonthly
					" + where_clause, inputs);
        }

        public DataTable select()
        {
            return select("");
        }

        public DataTable selectPK(long ID)
        {
            return select(@"where ID=@ID"
                , ID);
        }

        public TBL_BillMonthly select2(string where_clause, params object[] inputs)
        {
            DataTable dt = select(where_clause, inputs);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_BillMonthly.ReadRow(dt.Rows[0]);
        }

        public TBL_BillMonthly selectPK2(long ID)
        {
            DataTable dt = selectPK(ID);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_BillMonthly.ReadRow(dt.Rows[0]);
        }

        public DataTable select_join(long ID)
        {
            return select_join("where BillMonthly.ID=@ID", ID);
        }

        public DataTable select_join()
        {
            return select_join("");
        }

        public DataTable select_join(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select BillMonthly.ID, BillMonthly.BillPeriodID, BillMonthly.ServiceFormID, BillMonthly.OrgID, BillMonthly.SiteID, BillMonthly.CostCentreID, BillMonthly.Email, BillMonthly.EffectiveDate, BillMonthly.TerminatedDate, BillMonthly.UnitPrice, BillMonthly.OneTimeCharge, BillMonthly.Remarks, BillMonthly.AssetID, BillMonthly.Username
					from BillMonthly
					" + where_clause, inputs);
        }

        public void insert
        (
            ref long? ID,
            long? BillPeriodID,
            long? ServiceFormID,
            long? OrgID,
            long? SiteID,
            long? CostCentreID,
            string Email,
            DateTime? EffectiveDate,
            DateTime? TerminatedDate,
            decimal? UnitPrice,
            decimal? OneTimeCharge,
            string Remarks,
            string AssetID,
            string Username
        )
        {

            m_db.Exec(@"
					insert into BillMonthly(
						BillPeriodID,
						ServiceFormID,
						OrgID,
						SiteID,
						CostCentreID,
						Email,
						EffectiveDate,
						TerminatedDate,
						UnitPrice,
						OneTimeCharge,
						Remarks,
						AssetID,
						Username
						)
					values(
						@BillPeriodID,
						@ServiceFormID,
						@OrgID,
						@SiteID,
						@CostCentreID,
						@Email,
						@EffectiveDate,
						@TerminatedDate,
						@UnitPrice,
						@OneTimeCharge,
						@Remarks,
						@AssetID,
						@Username
						)
					", BillPeriodID, ServiceFormID, OrgID, SiteID, CostCentreID, Email, EffectiveDate, TerminatedDate, UnitPrice, OneTimeCharge, Remarks, AssetID, Username);

            ID = m_db.SelectInt("select IDENT_CURRENT('BillMonthly')");
        }

        public void insert
        (
            long? BillPeriodID,
            long? ServiceFormID,
            long? OrgID,
            long? SiteID,
            long? CostCentreID,
            string Email,
            DateTime? EffectiveDate,
            DateTime? TerminatedDate,
            decimal? UnitPrice,
            decimal? OneTimeCharge,
            string Remarks,
            string AssetID,
            string Username
        )
        {
            m_db.Exec(@"
					insert into BillMonthly(
						BillPeriodID,
						ServiceFormID,
						OrgID,
						SiteID,
						CostCentreID,
						Email,
						EffectiveDate,
						TerminatedDate,
						UnitPrice,
						OneTimeCharge,
						Remarks,
						AssetID,
						Username
						)
					values(
						@BillPeriodID,
						@ServiceFormID,
						@OrgID,
						@SiteID,
						@CostCentreID,
						@Email,
						@EffectiveDate,
						@TerminatedDate,
						@UnitPrice,
						@OneTimeCharge,
						@Remarks,
						@AssetID,
						@Username
						)
					", BillPeriodID, ServiceFormID, OrgID, SiteID, CostCentreID, Email, EffectiveDate, TerminatedDate, UnitPrice, OneTimeCharge, Remarks, AssetID, Username);
        }

        public void update
        (
            long ID,
            long? BillPeriodID,
            long? ServiceFormID,
            long? OrgID,
            long? SiteID,
            long? CostCentreID,
            string Email,
            DateTime? EffectiveDate,
            DateTime? TerminatedDate,
            decimal? UnitPrice,
            decimal? OneTimeCharge,
            string Remarks,
            string AssetID,
            string Username
        )
        {
            int count = m_db.SelectCount(@"select * from BillMonthly where ID=@ID", ID);
            if (count == 0)
                throw new Exception("BillMonthly.update error. ID does not exists");

            m_db.Exec(@"
					update BillMonthly
					set
						BillPeriodID = @BillPeriodID,
						ServiceFormID = @ServiceFormID,
						OrgID = @OrgID,
						SiteID = @SiteID,
						CostCentreID = @CostCentreID,
						Email = @Email,
						EffectiveDate = @EffectiveDate,
						TerminatedDate = @TerminatedDate,
						UnitPrice = @UnitPrice,
						OneTimeCharge = @OneTimeCharge,
						Remarks = @Remarks,
						AssetID = @AssetID,
						Username = @Username
					where ID=@ID
					",
                BillPeriodID,
                ServiceFormID,
                OrgID,
                SiteID,
                CostCentreID,
                Email,
                EffectiveDate,
                TerminatedDate,
                UnitPrice,
                OneTimeCharge,
                Remarks,
                AssetID,
                Username,
                ID
            );
        }

        public void delete(long ID)
        {
            int count = m_db.SelectCount(@"select * from BillMonthly where ID=@ID", ID);
            if (count == 0)
                throw new Exception("BillMonthly.delete error. ID does not exists");

            m_db.Exec(@"delete from BillMonthly where ID=@ID", ID);
        }

    }

    #endregion

    #region BillPeriod
    //**********************************************************
    //  BillPeriod
    //**********************************************************
    CMD_BillPeriod m_BillPeriod = null;
    public CMD_BillPeriod BillPeriod
    {
        get
        {
            if (m_BillPeriod == null)
                m_BillPeriod = new CMD_BillPeriod(this);
            return m_BillPeriod;
        }
    }

    [Serializable]
    public class TBL_BillPeriod
    {
        public long ID { get; set; }
        public string Year0 { get; set; }
        public string Month0 { get; set; }
        public DateTime StartDate { get; set; }
        public DateTime EndDate { get; set; }
        public int Locked { get; set; }

        public TBL_BillPeriod()
        {
            this.ID = 0;
            this.Year0 = "";
            this.Month0 = "";
            this.StartDate = Convert.ToDateTime("1900-01-01 00:00:00");
            this.EndDate = Convert.ToDateTime("1900-01-01 00:00:00");
            this.Locked = 0;
        }

        public TBL_BillPeriod(long ID, string Year0, string Month0, DateTime StartDate, DateTime EndDate, int Locked)
        {
            this.ID = ID;
            this.Year0 = Year0;
            this.Month0 = Month0;
            this.StartDate = StartDate;
            this.EndDate = EndDate;
            this.Locked = Locked;
        }

        public void CopyTo(ref TBL_BillPeriod to)
        {
            to.ID = this.ID;
            to.Year0 = this.Year0;
            to.Month0 = this.Month0;
            to.StartDate = this.StartDate;
            to.EndDate = this.EndDate;
            to.Locked = this.Locked;
        }

        public bool IsSame(TBL_BillPeriod x)
        {
            return (
                this.ID == x.ID &&
                this.Year0 == x.Year0 &&
                this.Month0 == x.Month0 &&
                this.StartDate == x.StartDate &&
                this.EndDate == x.EndDate &&
                this.Locked == x.Locked
            );
        }

        public static TBL_BillPeriod ReadRow(DataRow row)
        {
            TBL_BillPeriod record = new TBL_BillPeriod();
            record.ID = get_long_value(row["ID"]);
            record.Year0 = get_string_value(row["Year0"]);
            record.Month0 = get_string_value(row["Month0"]);
            record.StartDate = get_DateTime_value(row["StartDate"]);
            record.EndDate = get_DateTime_value(row["EndDate"]);
            record.Locked = get_int_value(row["Locked"]);
            return record;
        }

        public static List<TBL_BillPeriod> ReadTable(DataTable dt)
        {
            List<TBL_BillPeriod> records = new List<TBL_BillPeriod>();
            foreach (DataRow row in dt.Rows)
                records.Add(ReadRow(row));
            return records;
        }
    }

    public class CMD_BillPeriod
    {
        private MyLib.DAL_MSSQL m_db = null;

        public CMD_BillPeriod(MyLib.DAL_MSSQL db)
        {
            m_db = db;
        }

        public DataTable select(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select ID, Year0, Month0, StartDate, EndDate, Locked
					from BillPeriod
					" + where_clause, inputs);
        }

        public DataTable select()
        {
            return select("");
        }

        public DataTable selectPK(long ID)
        {
            return select(@"where ID=@ID"
                , ID);
        }

        public TBL_BillPeriod select2(string where_clause, params object[] inputs)
        {
            DataTable dt = select(where_clause, inputs);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_BillPeriod.ReadRow(dt.Rows[0]);
        }

        public TBL_BillPeriod selectPK2(long ID)
        {
            DataTable dt = selectPK(ID);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_BillPeriod.ReadRow(dt.Rows[0]);
        }

        public DataTable select_join(long ID)
        {
            return select_join("where BillPeriod.ID=@ID", ID);
        }

        public DataTable select_join()
        {
            return select_join("");
        }

        public DataTable select_join(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select BillPeriod.ID, BillPeriod.Year0, BillPeriod.Month0, BillPeriod.StartDate, BillPeriod.EndDate, BillPeriod.Locked
					from BillPeriod
					" + where_clause, inputs);
        }

        public void insert
        (
            ref long? ID,
            string Year0,
            string Month0,
            DateTime? StartDate,
            DateTime? EndDate,
            int? Locked
        )
        {

            m_db.Exec(@"
					insert into BillPeriod(
						Year0,
						Month0,
						StartDate,
						EndDate,
						Locked
						)
					values(
						@Year0,
						@Month0,
						@StartDate,
						@EndDate,
						@Locked
						)
					", Year0, Month0, StartDate, EndDate, Locked);

            ID = m_db.SelectInt("select IDENT_CURRENT('BillPeriod')");
        }

        public void insert
        (
            string Year0,
            string Month0,
            DateTime? StartDate,
            DateTime? EndDate,
            int? Locked
        )
        {
            m_db.Exec(@"
					insert into BillPeriod(
						Year0,
						Month0,
						StartDate,
						EndDate,
						Locked
						)
					values(
						@Year0,
						@Month0,
						@StartDate,
						@EndDate,
						@Locked
						)
					", Year0, Month0, StartDate, EndDate, Locked);
        }

        public void update
        (
            long ID,
            string Year0,
            string Month0,
            DateTime? StartDate,
            DateTime? EndDate,
            int? Locked
        )
        {
            int count = m_db.SelectCount(@"select * from BillPeriod where ID=@ID", ID);
            if (count == 0)
                throw new Exception("BillPeriod.update error. ID does not exists");

            m_db.Exec(@"
					update BillPeriod
					set
						Year0 = @Year0,
						Month0 = @Month0,
						StartDate = @StartDate,
						EndDate = @EndDate,
						Locked = @Locked
					where ID=@ID
					",
                Year0,
                Month0,
                StartDate,
                EndDate,
                Locked,
                ID
            );
        }

        public void delete(long ID)
        {
            int count = m_db.SelectCount(@"select * from BillPeriod where ID=@ID", ID);
            if (count == 0)
                throw new Exception("BillPeriod.delete error. ID does not exists");

            m_db.Exec(@"delete from BillPeriod where ID=@ID", ID);
        }

    }

    #endregion

    #region BillPricing
    //**********************************************************
    //  BillPricing
    //**********************************************************
    CMD_BillPricing m_BillPricing = null;
    public CMD_BillPricing BillPricing
    {
        get
        {
            if (m_BillPricing == null)
                m_BillPricing = new CMD_BillPricing(this);
            return m_BillPricing;
        }
    }

    [Serializable]
    public class TBL_BillPricing
    {
        public long ID { get; set; }
        public long BillPeriodIDFrom { get; set; }
        public long BillPeriodIDTo { get; set; }
        public string BillItem { get; set; }
        public decimal ValueDec { get; set; }
        public string ValueStr { get; set; }

        public TBL_BillPricing()
        {
            this.ID = 0;
            this.BillPeriodIDFrom = 0;
            this.BillPeriodIDTo = 0;
            this.BillItem = "";
            this.ValueDec = 0M;
            this.ValueStr = "";
        }

        public TBL_BillPricing(long ID, long BillPeriodIDFrom, long BillPeriodIDTo, string BillItem, decimal ValueDec, string ValueStr)
        {
            this.ID = ID;
            this.BillPeriodIDFrom = BillPeriodIDFrom;
            this.BillPeriodIDTo = BillPeriodIDTo;
            this.BillItem = BillItem;
            this.ValueDec = ValueDec;
            this.ValueStr = ValueStr;
        }

        public void CopyTo(ref TBL_BillPricing to)
        {
            to.ID = this.ID;
            to.BillPeriodIDFrom = this.BillPeriodIDFrom;
            to.BillPeriodIDTo = this.BillPeriodIDTo;
            to.BillItem = this.BillItem;
            to.ValueDec = this.ValueDec;
            to.ValueStr = this.ValueStr;
        }

        public bool IsSame(TBL_BillPricing x)
        {
            return (
                this.ID == x.ID &&
                this.BillPeriodIDFrom == x.BillPeriodIDFrom &&
                this.BillPeriodIDTo == x.BillPeriodIDTo &&
                this.BillItem == x.BillItem &&
                this.ValueDec == x.ValueDec &&
                this.ValueStr == x.ValueStr
            );
        }

        public static TBL_BillPricing ReadRow(DataRow row)
        {
            TBL_BillPricing record = new TBL_BillPricing();
            record.ID = get_long_value(row["ID"]);
            record.BillPeriodIDFrom = get_long_value(row["BillPeriodIDFrom"]);
            record.BillPeriodIDTo = get_long_value(row["BillPeriodIDTo"]);
            record.BillItem = get_string_value(row["BillItem"]);
            record.ValueDec = get_decimal_value(row["ValueDec"]);
            record.ValueStr = get_string_value(row["ValueStr"]);
            return record;
        }

        public static List<TBL_BillPricing> ReadTable(DataTable dt)
        {
            List<TBL_BillPricing> records = new List<TBL_BillPricing>();
            foreach (DataRow row in dt.Rows)
                records.Add(ReadRow(row));
            return records;
        }
    }

    public class CMD_BillPricing
    {
        private MyLib.DAL_MSSQL m_db = null;

        public CMD_BillPricing(MyLib.DAL_MSSQL db)
        {
            m_db = db;
        }

        public DataTable select(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select ID, BillPeriodIDFrom, BillPeriodIDTo, BillItem, ValueDec, ValueStr
					from BillPricing
					" + where_clause, inputs);
        }

        public DataTable select()
        {
            return select("");
        }

        public DataTable selectPK(long ID)
        {
            return select(@"where ID=@ID"
                , ID);
        }

        public TBL_BillPricing select2(string where_clause, params object[] inputs)
        {
            DataTable dt = select(where_clause, inputs);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_BillPricing.ReadRow(dt.Rows[0]);
        }

        public TBL_BillPricing selectPK2(long ID)
        {
            DataTable dt = selectPK(ID);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_BillPricing.ReadRow(dt.Rows[0]);
        }

        public DataTable select_join(long ID)
        {
            return select_join("where BillPricing.ID=@ID", ID);
        }

        public DataTable select_join()
        {
            return select_join("");
        }

        public DataTable select_join(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select BillPricing.ID, BillPricing.BillPeriodIDFrom, BillPricing.BillPeriodIDTo, BillPricing.BillItem, BillPricing.ValueDec, BillPricing.ValueStr
					from BillPricing
					" + where_clause, inputs);
        }

        public void insert
        (
            ref long? ID,
            long? BillPeriodIDFrom,
            long? BillPeriodIDTo,
            string BillItem,
            decimal? ValueDec,
            string ValueStr
        )
        {

            m_db.Exec(@"
					insert into BillPricing(
						BillPeriodIDFrom,
						BillPeriodIDTo,
						BillItem,
						ValueDec,
						ValueStr
						)
					values(
						@BillPeriodIDFrom,
						@BillPeriodIDTo,
						@BillItem,
						@ValueDec,
						@ValueStr
						)
					", BillPeriodIDFrom, BillPeriodIDTo, BillItem, ValueDec, ValueStr);

            ID = m_db.SelectInt("select IDENT_CURRENT('BillPricing')");
        }

        public void insert
        (
            long? BillPeriodIDFrom,
            long? BillPeriodIDTo,
            string BillItem,
            decimal? ValueDec,
            string ValueStr
        )
        {
            m_db.Exec(@"
					insert into BillPricing(
						BillPeriodIDFrom,
						BillPeriodIDTo,
						BillItem,
						ValueDec,
						ValueStr
						)
					values(
						@BillPeriodIDFrom,
						@BillPeriodIDTo,
						@BillItem,
						@ValueDec,
						@ValueStr
						)
					", BillPeriodIDFrom, BillPeriodIDTo, BillItem, ValueDec, ValueStr);
        }

        public void update
        (
            long ID,
            long? BillPeriodIDFrom,
            long? BillPeriodIDTo,
            string BillItem,
            decimal? ValueDec,
            string ValueStr
        )
        {
            int count = m_db.SelectCount(@"select * from BillPricing where ID=@ID", ID);
            if (count == 0)
                throw new Exception("BillPricing.update error. ID does not exists");

            m_db.Exec(@"
					update BillPricing
					set
						BillPeriodIDFrom = @BillPeriodIDFrom,
						BillPeriodIDTo = @BillPeriodIDTo,
						BillItem = @BillItem,
						ValueDec = @ValueDec,
						ValueStr = @ValueStr
					where ID=@ID
					",
                BillPeriodIDFrom,
                BillPeriodIDTo,
                BillItem,
                ValueDec,
                ValueStr,
                ID
            );
        }

        public void delete(long ID)
        {
            int count = m_db.SelectCount(@"select * from BillPricing where ID=@ID", ID);
            if (count == 0)
                throw new Exception("BillPricing.delete error. ID does not exists");

            m_db.Exec(@"delete from BillPricing where ID=@ID", ID);
        }

    }

    #endregion

    #region BillReportData_1
    //**********************************************************
    //  BillReportData_1
    //**********************************************************
    CMD_BillReportData_1 m_BillReportData_1 = null;
    public CMD_BillReportData_1 BillReportData_1
    {
        get
        {
            if (m_BillReportData_1 == null)
                m_BillReportData_1 = new CMD_BillReportData_1(this);
            return m_BillReportData_1;
        }
    }

    [Serializable]
    public class TBL_BillReportData_1
    {
        public long ID { get; set; }
        public long BillReportRepositoryID { get; set; }
        public long BillReportTemplateID { get; set; }
        public long BillPeriodID { get; set; }
        public long Version { get; set; }
        public string Year0 { get; set; }
        public string Month0 { get; set; }
        public DateTime StartDate { get; set; }
        public DateTime EndDate { get; set; }
        public string OrgIDName { get; set; }
        public string SiteIDName { get; set; }
        public string CostCentreIDName { get; set; }
        public long ServiceFormID { get; set; }
        public long OrgID { get; set; }
        public long SiteID { get; set; }
        public long CostCentreID { get; set; }
        public string Email { get; set; }
        public DateTime EffectiveDate { get; set; }
        public DateTime TerminatedDate { get; set; }
        public decimal UnitPrice { get; set; }
        public decimal OneTimeCharge { get; set; }
        public string Remarks { get; set; }
        public string AssetID { get; set; }
        public string Username { get; set; }

        public TBL_BillReportData_1()
        {
            this.ID = 0;
            this.BillReportRepositoryID = 0;
            this.BillReportTemplateID = 0;
            this.BillPeriodID = 0;
            this.Version = 0;
            this.Year0 = "";
            this.Month0 = "";
            this.StartDate = Convert.ToDateTime("1900-01-01 00:00:00");
            this.EndDate = Convert.ToDateTime("1900-01-01 00:00:00");
            this.OrgIDName = "";
            this.SiteIDName = "";
            this.CostCentreIDName = "";
            this.ServiceFormID = 0;
            this.OrgID = 0;
            this.SiteID = 0;
            this.CostCentreID = 0;
            this.Email = "";
            this.EffectiveDate = Convert.ToDateTime("1900-01-01 00:00:00");
            this.TerminatedDate = Convert.ToDateTime("1900-01-01 00:00:00");
            this.UnitPrice = 0M;
            this.OneTimeCharge = 0M;
            this.Remarks = "";
            this.AssetID = "";
            this.Username = "";
        }

        public TBL_BillReportData_1(long ID, long BillReportRepositoryID, long BillReportTemplateID, long BillPeriodID, long Version, string Year0, string Month0, DateTime StartDate, DateTime EndDate, string OrgIDName, string SiteIDName, string CostCentreIDName, long ServiceFormID, long OrgID, long SiteID, long CostCentreID, string Email, DateTime EffectiveDate, DateTime TerminatedDate, decimal UnitPrice, decimal OneTimeCharge, string Remarks, string AssetID, string Username)
        {
            this.ID = ID;
            this.BillReportRepositoryID = BillReportRepositoryID;
            this.BillReportTemplateID = BillReportTemplateID;
            this.BillPeriodID = BillPeriodID;
            this.Version = Version;
            this.Year0 = Year0;
            this.Month0 = Month0;
            this.StartDate = StartDate;
            this.EndDate = EndDate;
            this.OrgIDName = OrgIDName;
            this.SiteIDName = SiteIDName;
            this.CostCentreIDName = CostCentreIDName;
            this.ServiceFormID = ServiceFormID;
            this.OrgID = OrgID;
            this.SiteID = SiteID;
            this.CostCentreID = CostCentreID;
            this.Email = Email;
            this.EffectiveDate = EffectiveDate;
            this.TerminatedDate = TerminatedDate;
            this.UnitPrice = UnitPrice;
            this.OneTimeCharge = OneTimeCharge;
            this.Remarks = Remarks;
            this.AssetID = AssetID;
            this.Username = Username;
        }

        public void CopyTo(ref TBL_BillReportData_1 to)
        {
            to.ID = this.ID;
            to.BillReportRepositoryID = this.BillReportRepositoryID;
            to.BillReportTemplateID = this.BillReportTemplateID;
            to.BillPeriodID = this.BillPeriodID;
            to.Version = this.Version;
            to.Year0 = this.Year0;
            to.Month0 = this.Month0;
            to.StartDate = this.StartDate;
            to.EndDate = this.EndDate;
            to.OrgIDName = this.OrgIDName;
            to.SiteIDName = this.SiteIDName;
            to.CostCentreIDName = this.CostCentreIDName;
            to.ServiceFormID = this.ServiceFormID;
            to.OrgID = this.OrgID;
            to.SiteID = this.SiteID;
            to.CostCentreID = this.CostCentreID;
            to.Email = this.Email;
            to.EffectiveDate = this.EffectiveDate;
            to.TerminatedDate = this.TerminatedDate;
            to.UnitPrice = this.UnitPrice;
            to.OneTimeCharge = this.OneTimeCharge;
            to.Remarks = this.Remarks;
            to.AssetID = this.AssetID;
            to.Username = this.Username;
        }

        public bool IsSame(TBL_BillReportData_1 x)
        {
            return (
                this.ID == x.ID &&
                this.BillReportRepositoryID == x.BillReportRepositoryID &&
                this.BillReportTemplateID == x.BillReportTemplateID &&
                this.BillPeriodID == x.BillPeriodID &&
                this.Version == x.Version &&
                this.Year0 == x.Year0 &&
                this.Month0 == x.Month0 &&
                this.StartDate == x.StartDate &&
                this.EndDate == x.EndDate &&
                this.OrgIDName == x.OrgIDName &&
                this.SiteIDName == x.SiteIDName &&
                this.CostCentreIDName == x.CostCentreIDName &&
                this.ServiceFormID == x.ServiceFormID &&
                this.OrgID == x.OrgID &&
                this.SiteID == x.SiteID &&
                this.CostCentreID == x.CostCentreID &&
                this.Email == x.Email &&
                this.EffectiveDate == x.EffectiveDate &&
                this.TerminatedDate == x.TerminatedDate &&
                this.UnitPrice == x.UnitPrice &&
                this.OneTimeCharge == x.OneTimeCharge &&
                this.Remarks == x.Remarks &&
                this.AssetID == x.AssetID &&
                this.Username == x.Username
            );
        }

        public static TBL_BillReportData_1 ReadRow(DataRow row)
        {
            TBL_BillReportData_1 record = new TBL_BillReportData_1();
            record.ID = get_long_value(row["ID"]);
            record.BillReportRepositoryID = get_long_value(row["BillReportRepositoryID"]);
            record.BillReportTemplateID = get_long_value(row["BillReportTemplateID"]);
            record.BillPeriodID = get_long_value(row["BillPeriodID"]);
            record.Version = get_long_value(row["Version"]);
            record.Year0 = get_string_value(row["Year0"]);
            record.Month0 = get_string_value(row["Month0"]);
            record.StartDate = get_DateTime_value(row["StartDate"]);
            record.EndDate = get_DateTime_value(row["EndDate"]);
            record.OrgIDName = get_string_value(row["OrgIDName"]);
            record.SiteIDName = get_string_value(row["SiteIDName"]);
            record.CostCentreIDName = get_string_value(row["CostCentreIDName"]);
            record.ServiceFormID = get_long_value(row["ServiceFormID"]);
            record.OrgID = get_long_value(row["OrgID"]);
            record.SiteID = get_long_value(row["SiteID"]);
            record.CostCentreID = get_long_value(row["CostCentreID"]);
            record.Email = get_string_value(row["Email"]);
            record.EffectiveDate = get_DateTime_value(row["EffectiveDate"]);
            record.TerminatedDate = get_DateTime_value(row["TerminatedDate"]);
            record.UnitPrice = get_decimal_value(row["UnitPrice"]);
            record.OneTimeCharge = get_decimal_value(row["OneTimeCharge"]);
            record.Remarks = get_string_value(row["Remarks"]);
            record.AssetID = get_string_value(row["AssetID"]);
            record.Username = get_string_value(row["Username"]);
            return record;
        }

        public static List<TBL_BillReportData_1> ReadTable(DataTable dt)
        {
            List<TBL_BillReportData_1> records = new List<TBL_BillReportData_1>();
            foreach (DataRow row in dt.Rows)
                records.Add(ReadRow(row));
            return records;
        }
    }

    public class CMD_BillReportData_1
    {
        private MyLib.DAL_MSSQL m_db = null;

        public CMD_BillReportData_1(MyLib.DAL_MSSQL db)
        {
            m_db = db;
        }

        public DataTable select(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select ID, BillReportRepositoryID, BillReportTemplateID, BillPeriodID, Version, Year0, Month0, StartDate, EndDate, OrgIDName, SiteIDName, CostCentreIDName, ServiceFormID, OrgID, SiteID, CostCentreID, Email, EffectiveDate, TerminatedDate, UnitPrice, OneTimeCharge, Remarks, AssetID, Username
					from BillReportData_1
					" + where_clause, inputs);
        }

        public DataTable select()
        {
            return select("");
        }

        public DataTable selectPK(long ID)
        {
            return select(@"where ID=@ID"
                , ID);
        }

        public TBL_BillReportData_1 select2(string where_clause, params object[] inputs)
        {
            DataTable dt = select(where_clause, inputs);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_BillReportData_1.ReadRow(dt.Rows[0]);
        }

        public TBL_BillReportData_1 selectPK2(long ID)
        {
            DataTable dt = selectPK(ID);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_BillReportData_1.ReadRow(dt.Rows[0]);
        }

        public DataTable select_join(long ID)
        {
            return select_join("where BillReportData_1.ID=@ID", ID);
        }

        public DataTable select_join()
        {
            return select_join("");
        }

        public DataTable select_join(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select BillReportData_1.ID, BillReportData_1.BillReportRepositoryID, BillReportData_1.BillReportTemplateID, BillReportData_1.BillPeriodID, BillReportData_1.Version, BillReportData_1.Year0, BillReportData_1.Month0, BillReportData_1.StartDate, BillReportData_1.EndDate, BillReportData_1.OrgIDName, BillReportData_1.SiteIDName, BillReportData_1.CostCentreIDName, BillReportData_1.ServiceFormID, BillReportData_1.OrgID, BillReportData_1.SiteID, BillReportData_1.CostCentreID, BillReportData_1.Email, BillReportData_1.EffectiveDate, BillReportData_1.TerminatedDate, BillReportData_1.UnitPrice, BillReportData_1.OneTimeCharge, BillReportData_1.Remarks, BillReportData_1.AssetID, BillReportData_1.Username
					from BillReportData_1
					" + where_clause, inputs);
        }

        public void insert
        (
            ref long? ID,
            long? BillReportRepositoryID,
            long? BillReportTemplateID,
            long? BillPeriodID,
            long? Version,
            string Year0,
            string Month0,
            DateTime? StartDate,
            DateTime? EndDate,
            string OrgIDName,
            string SiteIDName,
            string CostCentreIDName,
            long? ServiceFormID,
            long? OrgID,
            long? SiteID,
            long? CostCentreID,
            string Email,
            DateTime? EffectiveDate,
            DateTime? TerminatedDate,
            decimal? UnitPrice,
            decimal? OneTimeCharge,
            string Remarks,
            string AssetID,
            string Username
        )
        {

            m_db.Exec(@"
					insert into BillReportData_1(
						BillReportRepositoryID,
						BillReportTemplateID,
						BillPeriodID,
						Version,
						Year0,
						Month0,
						StartDate,
						EndDate,
						OrgIDName,
						SiteIDName,
						CostCentreIDName,
						ServiceFormID,
						OrgID,
						SiteID,
						CostCentreID,
						Email,
						EffectiveDate,
						TerminatedDate,
						UnitPrice,
						OneTimeCharge,
						Remarks,
						AssetID,
						Username
						)
					values(
						@BillReportRepositoryID,
						@BillReportTemplateID,
						@BillPeriodID,
						@Version,
						@Year0,
						@Month0,
						@StartDate,
						@EndDate,
						@OrgIDName,
						@SiteIDName,
						@CostCentreIDName,
						@ServiceFormID,
						@OrgID,
						@SiteID,
						@CostCentreID,
						@Email,
						@EffectiveDate,
						@TerminatedDate,
						@UnitPrice,
						@OneTimeCharge,
						@Remarks,
						@AssetID,
						@Username
						)
					", BillReportRepositoryID, BillReportTemplateID, BillPeriodID, Version, Year0, Month0, StartDate, EndDate, OrgIDName, SiteIDName, CostCentreIDName, ServiceFormID, OrgID, SiteID, CostCentreID, Email, EffectiveDate, TerminatedDate, UnitPrice, OneTimeCharge, Remarks, AssetID, Username);

            ID = m_db.SelectInt("select IDENT_CURRENT('BillReportData_1')");
        }

        public void insert
        (
            long? BillReportRepositoryID,
            long? BillReportTemplateID,
            long? BillPeriodID,
            long? Version,
            string Year0,
            string Month0,
            DateTime? StartDate,
            DateTime? EndDate,
            string OrgIDName,
            string SiteIDName,
            string CostCentreIDName,
            long? ServiceFormID,
            long? OrgID,
            long? SiteID,
            long? CostCentreID,
            string Email,
            DateTime? EffectiveDate,
            DateTime? TerminatedDate,
            decimal? UnitPrice,
            decimal? OneTimeCharge,
            string Remarks,
            string AssetID,
            string Username
        )
        {
            m_db.Exec(@"
					insert into BillReportData_1(
						BillReportRepositoryID,
						BillReportTemplateID,
						BillPeriodID,
						Version,
						Year0,
						Month0,
						StartDate,
						EndDate,
						OrgIDName,
						SiteIDName,
						CostCentreIDName,
						ServiceFormID,
						OrgID,
						SiteID,
						CostCentreID,
						Email,
						EffectiveDate,
						TerminatedDate,
						UnitPrice,
						OneTimeCharge,
						Remarks,
						AssetID,
						Username
						)
					values(
						@BillReportRepositoryID,
						@BillReportTemplateID,
						@BillPeriodID,
						@Version,
						@Year0,
						@Month0,
						@StartDate,
						@EndDate,
						@OrgIDName,
						@SiteIDName,
						@CostCentreIDName,
						@ServiceFormID,
						@OrgID,
						@SiteID,
						@CostCentreID,
						@Email,
						@EffectiveDate,
						@TerminatedDate,
						@UnitPrice,
						@OneTimeCharge,
						@Remarks,
						@AssetID,
						@Username
						)
					", BillReportRepositoryID, BillReportTemplateID, BillPeriodID, Version, Year0, Month0, StartDate, EndDate, OrgIDName, SiteIDName, CostCentreIDName, ServiceFormID, OrgID, SiteID, CostCentreID, Email, EffectiveDate, TerminatedDate, UnitPrice, OneTimeCharge, Remarks, AssetID, Username);
        }

        public void update
        (
            long ID,
            long? BillReportRepositoryID,
            long? BillReportTemplateID,
            long? BillPeriodID,
            long? Version,
            string Year0,
            string Month0,
            DateTime? StartDate,
            DateTime? EndDate,
            string OrgIDName,
            string SiteIDName,
            string CostCentreIDName,
            long? ServiceFormID,
            long? OrgID,
            long? SiteID,
            long? CostCentreID,
            string Email,
            DateTime? EffectiveDate,
            DateTime? TerminatedDate,
            decimal? UnitPrice,
            decimal? OneTimeCharge,
            string Remarks,
            string AssetID,
            string Username
        )
        {
            int count = m_db.SelectCount(@"select * from BillReportData_1 where ID=@ID", ID);
            if (count == 0)
                throw new Exception("BillReportData_1.update error. ID does not exists");

            m_db.Exec(@"
					update BillReportData_1
					set
						BillReportRepositoryID = @BillReportRepositoryID,
						BillReportTemplateID = @BillReportTemplateID,
						BillPeriodID = @BillPeriodID,
						Version = @Version,
						Year0 = @Year0,
						Month0 = @Month0,
						StartDate = @StartDate,
						EndDate = @EndDate,
						OrgIDName = @OrgIDName,
						SiteIDName = @SiteIDName,
						CostCentreIDName = @CostCentreIDName,
						ServiceFormID = @ServiceFormID,
						OrgID = @OrgID,
						SiteID = @SiteID,
						CostCentreID = @CostCentreID,
						Email = @Email,
						EffectiveDate = @EffectiveDate,
						TerminatedDate = @TerminatedDate,
						UnitPrice = @UnitPrice,
						OneTimeCharge = @OneTimeCharge,
						Remarks = @Remarks,
						AssetID = @AssetID,
						Username = @Username
					where ID=@ID
					",
                BillReportRepositoryID,
                BillReportTemplateID,
                BillPeriodID,
                Version,
                Year0,
                Month0,
                StartDate,
                EndDate,
                OrgIDName,
                SiteIDName,
                CostCentreIDName,
                ServiceFormID,
                OrgID,
                SiteID,
                CostCentreID,
                Email,
                EffectiveDate,
                TerminatedDate,
                UnitPrice,
                OneTimeCharge,
                Remarks,
                AssetID,
                Username,
                ID
            );
        }

        public void delete(long ID)
        {
            int count = m_db.SelectCount(@"select * from BillReportData_1 where ID=@ID", ID);
            if (count == 0)
                throw new Exception("BillReportData_1.delete error. ID does not exists");

            m_db.Exec(@"delete from BillReportData_1 where ID=@ID", ID);
        }

    }

    #endregion

    #region BillReportData_9
    //**********************************************************
    //  BillReportData_9
    //**********************************************************
    CMD_BillReportData_9 m_BillReportData_9 = null;
    public CMD_BillReportData_9 BillReportData_9
    {
        get
        {
            if (m_BillReportData_9 == null)
                m_BillReportData_9 = new CMD_BillReportData_9(this);
            return m_BillReportData_9;
        }
    }

    [Serializable]
    public class TBL_BillReportData_9
    {
        public long ID { get; set; }
        public long BillReportRepositoryID { get; set; }
        public long BillReportTemplateID { get; set; }
        public long BillPeriodID { get; set; }
        public long Version { get; set; }
        public string Year0 { get; set; }
        public string Month0 { get; set; }
        public DateTime StartDate { get; set; }
        public DateTime EndDate { get; set; }
        public string OrgIDName { get; set; }
        public string SiteIDName { get; set; }
        public string CostCentreIDName { get; set; }
        public long ServiceFormID { get; set; }
        public long OrgID { get; set; }
        public long SiteID { get; set; }
        public long CostCentreID { get; set; }
        public string Email { get; set; }
        public DateTime EffectiveDate { get; set; }
        public DateTime TerminatedDate { get; set; }
        public decimal UnitPrice { get; set; }
        public decimal OneTimeCharge { get; set; }
        public string Remarks { get; set; }
        public string AssetID { get; set; }
        public string Username { get; set; }

        public TBL_BillReportData_9()
        {
            this.ID = 0;
            this.BillReportRepositoryID = 0;
            this.BillReportTemplateID = 0;
            this.BillPeriodID = 0;
            this.Version = 0;
            this.Year0 = "";
            this.Month0 = "";
            this.StartDate = Convert.ToDateTime("1900-01-01 00:00:00");
            this.EndDate = Convert.ToDateTime("1900-01-01 00:00:00");
            this.OrgIDName = "";
            this.SiteIDName = "";
            this.CostCentreIDName = "";
            this.ServiceFormID = 0;
            this.OrgID = 0;
            this.SiteID = 0;
            this.CostCentreID = 0;
            this.Email = "";
            this.EffectiveDate = Convert.ToDateTime("1900-01-01 00:00:00");
            this.TerminatedDate = Convert.ToDateTime("1900-01-01 00:00:00");
            this.UnitPrice = 0M;
            this.OneTimeCharge = 0M;
            this.Remarks = "";
            this.AssetID = "";
            this.Username = "";
        }

        public TBL_BillReportData_9(long ID, long BillReportRepositoryID, long BillReportTemplateID, long BillPeriodID, long Version, string Year0, string Month0, DateTime StartDate, DateTime EndDate, string OrgIDName, string SiteIDName, string CostCentreIDName, long ServiceFormID, long OrgID, long SiteID, long CostCentreID, string Email, DateTime EffectiveDate, DateTime TerminatedDate, decimal UnitPrice, decimal OneTimeCharge, string Remarks, string AssetID, string Username)
        {
            this.ID = ID;
            this.BillReportRepositoryID = BillReportRepositoryID;
            this.BillReportTemplateID = BillReportTemplateID;
            this.BillPeriodID = BillPeriodID;
            this.Version = Version;
            this.Year0 = Year0;
            this.Month0 = Month0;
            this.StartDate = StartDate;
            this.EndDate = EndDate;
            this.OrgIDName = OrgIDName;
            this.SiteIDName = SiteIDName;
            this.CostCentreIDName = CostCentreIDName;
            this.ServiceFormID = ServiceFormID;
            this.OrgID = OrgID;
            this.SiteID = SiteID;
            this.CostCentreID = CostCentreID;
            this.Email = Email;
            this.EffectiveDate = EffectiveDate;
            this.TerminatedDate = TerminatedDate;
            this.UnitPrice = UnitPrice;
            this.OneTimeCharge = OneTimeCharge;
            this.Remarks = Remarks;
            this.AssetID = AssetID;
            this.Username = Username;
        }

        public void CopyTo(ref TBL_BillReportData_9 to)
        {
            to.ID = this.ID;
            to.BillReportRepositoryID = this.BillReportRepositoryID;
            to.BillReportTemplateID = this.BillReportTemplateID;
            to.BillPeriodID = this.BillPeriodID;
            to.Version = this.Version;
            to.Year0 = this.Year0;
            to.Month0 = this.Month0;
            to.StartDate = this.StartDate;
            to.EndDate = this.EndDate;
            to.OrgIDName = this.OrgIDName;
            to.SiteIDName = this.SiteIDName;
            to.CostCentreIDName = this.CostCentreIDName;
            to.ServiceFormID = this.ServiceFormID;
            to.OrgID = this.OrgID;
            to.SiteID = this.SiteID;
            to.CostCentreID = this.CostCentreID;
            to.Email = this.Email;
            to.EffectiveDate = this.EffectiveDate;
            to.TerminatedDate = this.TerminatedDate;
            to.UnitPrice = this.UnitPrice;
            to.OneTimeCharge = this.OneTimeCharge;
            to.Remarks = this.Remarks;
            to.AssetID = this.AssetID;
            to.Username = this.Username;
        }

        public bool IsSame(TBL_BillReportData_9 x)
        {
            return (
                this.ID == x.ID &&
                this.BillReportRepositoryID == x.BillReportRepositoryID &&
                this.BillReportTemplateID == x.BillReportTemplateID &&
                this.BillPeriodID == x.BillPeriodID &&
                this.Version == x.Version &&
                this.Year0 == x.Year0 &&
                this.Month0 == x.Month0 &&
                this.StartDate == x.StartDate &&
                this.EndDate == x.EndDate &&
                this.OrgIDName == x.OrgIDName &&
                this.SiteIDName == x.SiteIDName &&
                this.CostCentreIDName == x.CostCentreIDName &&
                this.ServiceFormID == x.ServiceFormID &&
                this.OrgID == x.OrgID &&
                this.SiteID == x.SiteID &&
                this.CostCentreID == x.CostCentreID &&
                this.Email == x.Email &&
                this.EffectiveDate == x.EffectiveDate &&
                this.TerminatedDate == x.TerminatedDate &&
                this.UnitPrice == x.UnitPrice &&
                this.OneTimeCharge == x.OneTimeCharge &&
                this.Remarks == x.Remarks &&
                this.AssetID == x.AssetID &&
                this.Username == x.Username
            );
        }

        public static TBL_BillReportData_9 ReadRow(DataRow row)
        {
            TBL_BillReportData_9 record = new TBL_BillReportData_9();
            record.ID = get_long_value(row["ID"]);
            record.BillReportRepositoryID = get_long_value(row["BillReportRepositoryID"]);
            record.BillReportTemplateID = get_long_value(row["BillReportTemplateID"]);
            record.BillPeriodID = get_long_value(row["BillPeriodID"]);
            record.Version = get_long_value(row["Version"]);
            record.Year0 = get_string_value(row["Year0"]);
            record.Month0 = get_string_value(row["Month0"]);
            record.StartDate = get_DateTime_value(row["StartDate"]);
            record.EndDate = get_DateTime_value(row["EndDate"]);
            record.OrgIDName = get_string_value(row["OrgIDName"]);
            record.SiteIDName = get_string_value(row["SiteIDName"]);
            record.CostCentreIDName = get_string_value(row["CostCentreIDName"]);
            record.ServiceFormID = get_long_value(row["ServiceFormID"]);
            record.OrgID = get_long_value(row["OrgID"]);
            record.SiteID = get_long_value(row["SiteID"]);
            record.CostCentreID = get_long_value(row["CostCentreID"]);
            record.Email = get_string_value(row["Email"]);
            record.EffectiveDate = get_DateTime_value(row["EffectiveDate"]);
            record.TerminatedDate = get_DateTime_value(row["TerminatedDate"]);
            record.UnitPrice = get_decimal_value(row["UnitPrice"]);
            record.OneTimeCharge = get_decimal_value(row["OneTimeCharge"]);
            record.Remarks = get_string_value(row["Remarks"]);
            record.AssetID = get_string_value(row["AssetID"]);
            record.Username = get_string_value(row["Username"]);
            return record;
        }

        public static List<TBL_BillReportData_9> ReadTable(DataTable dt)
        {
            List<TBL_BillReportData_9> records = new List<TBL_BillReportData_9>();
            foreach (DataRow row in dt.Rows)
                records.Add(ReadRow(row));
            return records;
        }
    }

    public class CMD_BillReportData_9
    {
        private MyLib.DAL_MSSQL m_db = null;

        public CMD_BillReportData_9(MyLib.DAL_MSSQL db)
        {
            m_db = db;
        }

        public DataTable select(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select ID, BillReportRepositoryID, BillReportTemplateID, BillPeriodID, Version, Year0, Month0, StartDate, EndDate, OrgIDName, SiteIDName, CostCentreIDName, ServiceFormID, OrgID, SiteID, CostCentreID, Email, EffectiveDate, TerminatedDate, UnitPrice, OneTimeCharge, Remarks, AssetID, Username
					from BillReportData_9
					" + where_clause, inputs);
        }

        public DataTable select()
        {
            return select("");
        }

        public DataTable selectPK(long ID)
        {
            return select(@"where ID=@ID"
                , ID);
        }

        public TBL_BillReportData_9 select2(string where_clause, params object[] inputs)
        {
            DataTable dt = select(where_clause, inputs);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_BillReportData_9.ReadRow(dt.Rows[0]);
        }

        public TBL_BillReportData_9 selectPK2(long ID)
        {
            DataTable dt = selectPK(ID);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_BillReportData_9.ReadRow(dt.Rows[0]);
        }

        public DataTable select_join(long ID)
        {
            return select_join("where BillReportData_9.ID=@ID", ID);
        }

        public DataTable select_join()
        {
            return select_join("");
        }

        public DataTable select_join(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select BillReportData_9.ID, BillReportData_9.BillReportRepositoryID, BillReportData_9.BillReportTemplateID, BillReportData_9.BillPeriodID, BillReportData_9.Version, BillReportData_9.Year0, BillReportData_9.Month0, BillReportData_9.StartDate, BillReportData_9.EndDate, BillReportData_9.OrgIDName, BillReportData_9.SiteIDName, BillReportData_9.CostCentreIDName, BillReportData_9.ServiceFormID, BillReportData_9.OrgID, BillReportData_9.SiteID, BillReportData_9.CostCentreID, BillReportData_9.Email, BillReportData_9.EffectiveDate, BillReportData_9.TerminatedDate, BillReportData_9.UnitPrice, BillReportData_9.OneTimeCharge, BillReportData_9.Remarks, BillReportData_9.AssetID, BillReportData_9.Username
					from BillReportData_9
					" + where_clause, inputs);
        }

        public void insert
        (
            ref long? ID,
            long? BillReportRepositoryID,
            long? BillReportTemplateID,
            long? BillPeriodID,
            long? Version,
            string Year0,
            string Month0,
            DateTime? StartDate,
            DateTime? EndDate,
            string OrgIDName,
            string SiteIDName,
            string CostCentreIDName,
            long? ServiceFormID,
            long? OrgID,
            long? SiteID,
            long? CostCentreID,
            string Email,
            DateTime? EffectiveDate,
            DateTime? TerminatedDate,
            decimal? UnitPrice,
            decimal? OneTimeCharge,
            string Remarks,
            string AssetID,
            string Username
        )
        {

            m_db.Exec(@"
					insert into BillReportData_9(
						BillReportRepositoryID,
						BillReportTemplateID,
						BillPeriodID,
						Version,
						Year0,
						Month0,
						StartDate,
						EndDate,
						OrgIDName,
						SiteIDName,
						CostCentreIDName,
						ServiceFormID,
						OrgID,
						SiteID,
						CostCentreID,
						Email,
						EffectiveDate,
						TerminatedDate,
						UnitPrice,
						OneTimeCharge,
						Remarks,
						AssetID,
						Username
						)
					values(
						@BillReportRepositoryID,
						@BillReportTemplateID,
						@BillPeriodID,
						@Version,
						@Year0,
						@Month0,
						@StartDate,
						@EndDate,
						@OrgIDName,
						@SiteIDName,
						@CostCentreIDName,
						@ServiceFormID,
						@OrgID,
						@SiteID,
						@CostCentreID,
						@Email,
						@EffectiveDate,
						@TerminatedDate,
						@UnitPrice,
						@OneTimeCharge,
						@Remarks,
						@AssetID,
						@Username
						)
					", BillReportRepositoryID, BillReportTemplateID, BillPeriodID, Version, Year0, Month0, StartDate, EndDate, OrgIDName, SiteIDName, CostCentreIDName, ServiceFormID, OrgID, SiteID, CostCentreID, Email, EffectiveDate, TerminatedDate, UnitPrice, OneTimeCharge, Remarks, AssetID, Username);

            ID = m_db.SelectInt("select IDENT_CURRENT('BillReportData_9')");
        }

        public void insert
        (
            long? BillReportRepositoryID,
            long? BillReportTemplateID,
            long? BillPeriodID,
            long? Version,
            string Year0,
            string Month0,
            DateTime? StartDate,
            DateTime? EndDate,
            string OrgIDName,
            string SiteIDName,
            string CostCentreIDName,
            long? ServiceFormID,
            long? OrgID,
            long? SiteID,
            long? CostCentreID,
            string Email,
            DateTime? EffectiveDate,
            DateTime? TerminatedDate,
            decimal? UnitPrice,
            decimal? OneTimeCharge,
            string Remarks,
            string AssetID,
            string Username
        )
        {
            m_db.Exec(@"
					insert into BillReportData_9(
						BillReportRepositoryID,
						BillReportTemplateID,
						BillPeriodID,
						Version,
						Year0,
						Month0,
						StartDate,
						EndDate,
						OrgIDName,
						SiteIDName,
						CostCentreIDName,
						ServiceFormID,
						OrgID,
						SiteID,
						CostCentreID,
						Email,
						EffectiveDate,
						TerminatedDate,
						UnitPrice,
						OneTimeCharge,
						Remarks,
						AssetID,
						Username
						)
					values(
						@BillReportRepositoryID,
						@BillReportTemplateID,
						@BillPeriodID,
						@Version,
						@Year0,
						@Month0,
						@StartDate,
						@EndDate,
						@OrgIDName,
						@SiteIDName,
						@CostCentreIDName,
						@ServiceFormID,
						@OrgID,
						@SiteID,
						@CostCentreID,
						@Email,
						@EffectiveDate,
						@TerminatedDate,
						@UnitPrice,
						@OneTimeCharge,
						@Remarks,
						@AssetID,
						@Username
						)
					", BillReportRepositoryID, BillReportTemplateID, BillPeriodID, Version, Year0, Month0, StartDate, EndDate, OrgIDName, SiteIDName, CostCentreIDName, ServiceFormID, OrgID, SiteID, CostCentreID, Email, EffectiveDate, TerminatedDate, UnitPrice, OneTimeCharge, Remarks, AssetID, Username);
        }

        public void update
        (
            long ID,
            long? BillReportRepositoryID,
            long? BillReportTemplateID,
            long? BillPeriodID,
            long? Version,
            string Year0,
            string Month0,
            DateTime? StartDate,
            DateTime? EndDate,
            string OrgIDName,
            string SiteIDName,
            string CostCentreIDName,
            long? ServiceFormID,
            long? OrgID,
            long? SiteID,
            long? CostCentreID,
            string Email,
            DateTime? EffectiveDate,
            DateTime? TerminatedDate,
            decimal? UnitPrice,
            decimal? OneTimeCharge,
            string Remarks,
            string AssetID,
            string Username
        )
        {
            int count = m_db.SelectCount(@"select * from BillReportData_9 where ID=@ID", ID);
            if (count == 0)
                throw new Exception("BillReportData_9.update error. ID does not exists");

            m_db.Exec(@"
					update BillReportData_9
					set
						BillReportRepositoryID = @BillReportRepositoryID,
						BillReportTemplateID = @BillReportTemplateID,
						BillPeriodID = @BillPeriodID,
						Version = @Version,
						Year0 = @Year0,
						Month0 = @Month0,
						StartDate = @StartDate,
						EndDate = @EndDate,
						OrgIDName = @OrgIDName,
						SiteIDName = @SiteIDName,
						CostCentreIDName = @CostCentreIDName,
						ServiceFormID = @ServiceFormID,
						OrgID = @OrgID,
						SiteID = @SiteID,
						CostCentreID = @CostCentreID,
						Email = @Email,
						EffectiveDate = @EffectiveDate,
						TerminatedDate = @TerminatedDate,
						UnitPrice = @UnitPrice,
						OneTimeCharge = @OneTimeCharge,
						Remarks = @Remarks,
						AssetID = @AssetID,
						Username = @Username
					where ID=@ID
					",
                BillReportRepositoryID,
                BillReportTemplateID,
                BillPeriodID,
                Version,
                Year0,
                Month0,
                StartDate,
                EndDate,
                OrgIDName,
                SiteIDName,
                CostCentreIDName,
                ServiceFormID,
                OrgID,
                SiteID,
                CostCentreID,
                Email,
                EffectiveDate,
                TerminatedDate,
                UnitPrice,
                OneTimeCharge,
                Remarks,
                AssetID,
                Username,
                ID
            );
        }

        public void delete(long ID)
        {
            int count = m_db.SelectCount(@"select * from BillReportData_9 where ID=@ID", ID);
            if (count == 0)
                throw new Exception("BillReportData_9.delete error. ID does not exists");

            m_db.Exec(@"delete from BillReportData_9 where ID=@ID", ID);
        }

    }

    #endregion

    #region BillReportRepository
    //**********************************************************
    //  BillReportRepository
    //**********************************************************
    CMD_BillReportRepository m_BillReportRepository = null;
    public CMD_BillReportRepository BillReportRepository
    {
        get
        {
            if (m_BillReportRepository == null)
                m_BillReportRepository = new CMD_BillReportRepository(this);
            return m_BillReportRepository;
        }
    }

    [Serializable]
    public class TBL_BillReportRepository
    {
        public long ID { get; set; }
        public long BillPeriodID { get; set; }
        public long BillReportTemplateID { get; set; }
        public string ReportFileName { get; set; }
        public byte[] ReportData { get; set; }
        public string ContentType { get; set; }
        public int IsReleased { get; set; }
        public long SiteID { get; set; }
        public long CostCentreID { get; set; }
        public long CreatedBy { get; set; }
        public DateTime CreatedDateTime { get; set; }
        public long ReleasedBy { get; set; }
        public DateTime ReleasedDateTime { get; set; }
        public string DownloadID { get; set; }
        public long UnReleasedBy { get; set; }
        public DateTime UnReleasedDateTime { get; set; }
        public long BillCustomerID { get; set; }
        public int Version { get; set; }
        public int IsLatest { get; set; }
        public string Thumbnail { get; set; }
        public int Locked { get; set; }

        public TBL_BillReportRepository()
        {
            this.ID = 0;
            this.BillPeriodID = 0;
            this.BillReportTemplateID = 0;
            this.ReportFileName = "";
            this.ReportData = new byte[0];
            this.ContentType = "";
            this.IsReleased = 0;
            this.SiteID = 0;
            this.CostCentreID = 0;
            this.CreatedBy = 0;
            this.CreatedDateTime = Convert.ToDateTime("1900-01-01 00:00:00");
            this.ReleasedBy = 0;
            this.ReleasedDateTime = Convert.ToDateTime("1900-01-01 00:00:00");
            this.DownloadID = "";
            this.UnReleasedBy = 0;
            this.UnReleasedDateTime = Convert.ToDateTime("1900-01-01 00:00:00");
            this.BillCustomerID = 0;
            this.Version = 0;
            this.IsLatest = 0;
            this.Thumbnail = "";
            this.Locked = 0;
        }

        public TBL_BillReportRepository(long ID, long BillPeriodID, long BillReportTemplateID, string ReportFileName, byte[] ReportData, string ContentType, int IsReleased, long SiteID, long CostCentreID, long CreatedBy, DateTime CreatedDateTime, long ReleasedBy, DateTime ReleasedDateTime, string DownloadID, long UnReleasedBy, DateTime UnReleasedDateTime, long BillCustomerID, int Version, int IsLatest, string Thumbnail, int Locked)
        {
            this.ID = ID;
            this.BillPeriodID = BillPeriodID;
            this.BillReportTemplateID = BillReportTemplateID;
            this.ReportFileName = ReportFileName;
            this.ReportData = ReportData;
            this.ContentType = ContentType;
            this.IsReleased = IsReleased;
            this.SiteID = SiteID;
            this.CostCentreID = CostCentreID;
            this.CreatedBy = CreatedBy;
            this.CreatedDateTime = CreatedDateTime;
            this.ReleasedBy = ReleasedBy;
            this.ReleasedDateTime = ReleasedDateTime;
            this.DownloadID = DownloadID;
            this.UnReleasedBy = UnReleasedBy;
            this.UnReleasedDateTime = UnReleasedDateTime;
            this.BillCustomerID = BillCustomerID;
            this.Version = Version;
            this.IsLatest = IsLatest;
            this.Thumbnail = Thumbnail;
            this.Locked = Locked;
        }

        public void CopyTo(ref TBL_BillReportRepository to)
        {
            to.ID = this.ID;
            to.BillPeriodID = this.BillPeriodID;
            to.BillReportTemplateID = this.BillReportTemplateID;
            to.ReportFileName = this.ReportFileName;
            to.ReportData = this.ReportData;
            to.ContentType = this.ContentType;
            to.IsReleased = this.IsReleased;
            to.SiteID = this.SiteID;
            to.CostCentreID = this.CostCentreID;
            to.CreatedBy = this.CreatedBy;
            to.CreatedDateTime = this.CreatedDateTime;
            to.ReleasedBy = this.ReleasedBy;
            to.ReleasedDateTime = this.ReleasedDateTime;
            to.DownloadID = this.DownloadID;
            to.UnReleasedBy = this.UnReleasedBy;
            to.UnReleasedDateTime = this.UnReleasedDateTime;
            to.BillCustomerID = this.BillCustomerID;
            to.Version = this.Version;
            to.IsLatest = this.IsLatest;
            to.Thumbnail = this.Thumbnail;
            to.Locked = this.Locked;
        }

        public bool IsSame(TBL_BillReportRepository x)
        {
            return (
                this.ID == x.ID &&
                this.BillPeriodID == x.BillPeriodID &&
                this.BillReportTemplateID == x.BillReportTemplateID &&
                this.ReportFileName == x.ReportFileName &&
                this.ReportData == x.ReportData &&
                this.ContentType == x.ContentType &&
                this.IsReleased == x.IsReleased &&
                this.SiteID == x.SiteID &&
                this.CostCentreID == x.CostCentreID &&
                this.CreatedBy == x.CreatedBy &&
                this.CreatedDateTime == x.CreatedDateTime &&
                this.ReleasedBy == x.ReleasedBy &&
                this.ReleasedDateTime == x.ReleasedDateTime &&
                this.DownloadID == x.DownloadID &&
                this.UnReleasedBy == x.UnReleasedBy &&
                this.UnReleasedDateTime == x.UnReleasedDateTime &&
                this.BillCustomerID == x.BillCustomerID &&
                this.Version == x.Version &&
                this.IsLatest == x.IsLatest &&
                this.Thumbnail == x.Thumbnail &&
                this.Locked == x.Locked
            );
        }

        public static TBL_BillReportRepository ReadRow(DataRow row)
        {
            TBL_BillReportRepository record = new TBL_BillReportRepository();
            record.ID = get_long_value(row["ID"]);
            record.BillPeriodID = get_long_value(row["BillPeriodID"]);
            record.BillReportTemplateID = get_long_value(row["BillReportTemplateID"]);
            record.ReportFileName = get_string_value(row["ReportFileName"]);
            record.ReportData = get_bytes_value(row["ReportData"]);
            record.ContentType = get_string_value(row["ContentType"]);
            record.IsReleased = get_int_value(row["IsReleased"]);
            record.SiteID = get_long_value(row["SiteID"]);
            record.CostCentreID = get_long_value(row["CostCentreID"]);
            record.CreatedBy = get_long_value(row["CreatedBy"]);
            record.CreatedDateTime = get_DateTime_value(row["CreatedDateTime"]);
            record.ReleasedBy = get_long_value(row["ReleasedBy"]);
            record.ReleasedDateTime = get_DateTime_value(row["ReleasedDateTime"]);
            record.DownloadID = get_string_value(row["DownloadID"]);
            record.UnReleasedBy = get_long_value(row["UnReleasedBy"]);
            record.UnReleasedDateTime = get_DateTime_value(row["UnReleasedDateTime"]);
            record.BillCustomerID = get_long_value(row["BillCustomerID"]);
            record.Version = get_int_value(row["Version"]);
            record.IsLatest = get_int_value(row["IsLatest"]);
            record.Thumbnail = get_string_value(row["Thumbnail"]);
            record.Locked = get_int_value(row["Locked"]);
            return record;
        }

        public static List<TBL_BillReportRepository> ReadTable(DataTable dt)
        {
            List<TBL_BillReportRepository> records = new List<TBL_BillReportRepository>();
            foreach (DataRow row in dt.Rows)
                records.Add(ReadRow(row));
            return records;
        }
    }

    public class CMD_BillReportRepository
    {
        private MyLib.DAL_MSSQL m_db = null;

        public CMD_BillReportRepository(MyLib.DAL_MSSQL db)
        {
            m_db = db;
        }

        public DataTable select(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select ID, BillPeriodID, BillReportTemplateID, ReportFileName, ReportData, ContentType, IsReleased, SiteID, CostCentreID, CreatedBy, CreatedDateTime, ReleasedBy, ReleasedDateTime, DownloadID, UnReleasedBy, UnReleasedDateTime, BillCustomerID, Version, IsLatest, Thumbnail, Locked
					from BillReportRepository
					" + where_clause, inputs);
        }

        public DataTable select()
        {
            return select("");
        }

        public DataTable selectPK(long ID)
        {
            return select(@"where ID=@ID"
                , ID);
        }

        public TBL_BillReportRepository select2(string where_clause, params object[] inputs)
        {
            DataTable dt = select(where_clause, inputs);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_BillReportRepository.ReadRow(dt.Rows[0]);
        }

        public TBL_BillReportRepository selectPK2(long ID)
        {
            DataTable dt = selectPK(ID);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_BillReportRepository.ReadRow(dt.Rows[0]);
        }

        public DataTable select_join(long ID)
        {
            return select_join("where BillReportRepository.ID=@ID", ID);
        }

        public DataTable select_join()
        {
            return select_join("");
        }

        public DataTable select_join(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select BillReportRepository.ID, BillReportRepository.BillPeriodID, BillReportRepository.BillReportTemplateID, BillReportRepository.ReportFileName, BillReportRepository.ReportData, BillReportRepository.ContentType, BillReportRepository.IsReleased, BillReportRepository.SiteID, BillReportRepository.CostCentreID, BillReportRepository.CreatedBy, BillReportRepository.CreatedDateTime, BillReportRepository.ReleasedBy, BillReportRepository.ReleasedDateTime, BillReportRepository.DownloadID, BillReportRepository.UnReleasedBy, BillReportRepository.UnReleasedDateTime, BillReportRepository.BillCustomerID, BillReportRepository.Version, BillReportRepository.IsLatest, BillReportRepository.Thumbnail, BillReportRepository.Locked
					from BillReportRepository
					" + where_clause, inputs);
        }

        public void insert
        (
            ref long? ID,
            long? BillPeriodID,
            long? BillReportTemplateID,
            string ReportFileName,
            byte[] ReportData,
            string ContentType,
            int? IsReleased,
            long? SiteID,
            long? CostCentreID,
            long? CreatedBy,
            DateTime? CreatedDateTime,
            long? ReleasedBy,
            DateTime? ReleasedDateTime,
            string DownloadID,
            long? UnReleasedBy,
            DateTime? UnReleasedDateTime,
            long? BillCustomerID,
            int? Version,
            int? IsLatest,
            string Thumbnail,
            int? Locked
        )
        {

            m_db.Exec(@"
					insert into BillReportRepository(
						BillPeriodID,
						BillReportTemplateID,
						ReportFileName,
						ReportData,
						ContentType,
						IsReleased,
						SiteID,
						CostCentreID,
						CreatedBy,
						CreatedDateTime,
						ReleasedBy,
						ReleasedDateTime,
						DownloadID,
						UnReleasedBy,
						UnReleasedDateTime,
						BillCustomerID,
						Version,
						IsLatest,
						Thumbnail,
						Locked
						)
					values(
						@BillPeriodID,
						@BillReportTemplateID,
						@ReportFileName,
						@ReportData,
						@ContentType,
						@IsReleased,
						@SiteID,
						@CostCentreID,
						@CreatedBy,
						@CreatedDateTime,
						@ReleasedBy,
						@ReleasedDateTime,
						@DownloadID,
						@UnReleasedBy,
						@UnReleasedDateTime,
						@BillCustomerID,
						@Version,
						@IsLatest,
						@Thumbnail,
						@Locked
						)
					", BillPeriodID, BillReportTemplateID, ReportFileName, ReportData, ContentType, IsReleased, SiteID, CostCentreID, CreatedBy, CreatedDateTime, ReleasedBy, ReleasedDateTime, DownloadID, UnReleasedBy, UnReleasedDateTime, BillCustomerID, Version, IsLatest, Thumbnail, Locked);

            ID = m_db.SelectInt("select IDENT_CURRENT('BillReportRepository')");
        }

        public void insert
        (
            long? BillPeriodID,
            long? BillReportTemplateID,
            string ReportFileName,
            byte[] ReportData,
            string ContentType,
            int? IsReleased,
            long? SiteID,
            long? CostCentreID,
            long? CreatedBy,
            DateTime? CreatedDateTime,
            long? ReleasedBy,
            DateTime? ReleasedDateTime,
            string DownloadID,
            long? UnReleasedBy,
            DateTime? UnReleasedDateTime,
            long? BillCustomerID,
            int? Version,
            int? IsLatest,
            string Thumbnail,
            int? Locked
        )
        {
            m_db.Exec(@"
					insert into BillReportRepository(
						BillPeriodID,
						BillReportTemplateID,
						ReportFileName,
						ReportData,
						ContentType,
						IsReleased,
						SiteID,
						CostCentreID,
						CreatedBy,
						CreatedDateTime,
						ReleasedBy,
						ReleasedDateTime,
						DownloadID,
						UnReleasedBy,
						UnReleasedDateTime,
						BillCustomerID,
						Version,
						IsLatest,
						Thumbnail,
						Locked
						)
					values(
						@BillPeriodID,
						@BillReportTemplateID,
						@ReportFileName,
						@ReportData,
						@ContentType,
						@IsReleased,
						@SiteID,
						@CostCentreID,
						@CreatedBy,
						@CreatedDateTime,
						@ReleasedBy,
						@ReleasedDateTime,
						@DownloadID,
						@UnReleasedBy,
						@UnReleasedDateTime,
						@BillCustomerID,
						@Version,
						@IsLatest,
						@Thumbnail,
						@Locked
						)
					", BillPeriodID, BillReportTemplateID, ReportFileName, ReportData, ContentType, IsReleased, SiteID, CostCentreID, CreatedBy, CreatedDateTime, ReleasedBy, ReleasedDateTime, DownloadID, UnReleasedBy, UnReleasedDateTime, BillCustomerID, Version, IsLatest, Thumbnail, Locked);
        }

        public void update
        (
            long ID,
            long? BillPeriodID,
            long? BillReportTemplateID,
            string ReportFileName,
            byte[] ReportData,
            string ContentType,
            int? IsReleased,
            long? SiteID,
            long? CostCentreID,
            long? CreatedBy,
            DateTime? CreatedDateTime,
            long? ReleasedBy,
            DateTime? ReleasedDateTime,
            string DownloadID,
            long? UnReleasedBy,
            DateTime? UnReleasedDateTime,
            long? BillCustomerID,
            int? Version,
            int? IsLatest,
            string Thumbnail,
            int? Locked
        )
        {
            int count = m_db.SelectCount(@"select * from BillReportRepository where ID=@ID", ID);
            if (count == 0)
                throw new Exception("BillReportRepository.update error. ID does not exists");

            m_db.Exec(@"
					update BillReportRepository
					set
						BillPeriodID = @BillPeriodID,
						BillReportTemplateID = @BillReportTemplateID,
						ReportFileName = @ReportFileName,
						ReportData = @ReportData,
						ContentType = @ContentType,
						IsReleased = @IsReleased,
						SiteID = @SiteID,
						CostCentreID = @CostCentreID,
						CreatedBy = @CreatedBy,
						CreatedDateTime = @CreatedDateTime,
						ReleasedBy = @ReleasedBy,
						ReleasedDateTime = @ReleasedDateTime,
						DownloadID = @DownloadID,
						UnReleasedBy = @UnReleasedBy,
						UnReleasedDateTime = @UnReleasedDateTime,
						BillCustomerID = @BillCustomerID,
						Version = @Version,
						IsLatest = @IsLatest,
						Thumbnail = @Thumbnail,
						Locked = @Locked
					where ID=@ID
					",
                BillPeriodID,
                BillReportTemplateID,
                ReportFileName,
                ReportData,
                ContentType,
                IsReleased,
                SiteID,
                CostCentreID,
                CreatedBy,
                CreatedDateTime,
                ReleasedBy,
                ReleasedDateTime,
                DownloadID,
                UnReleasedBy,
                UnReleasedDateTime,
                BillCustomerID,
                Version,
                IsLatest,
                Thumbnail,
                Locked,
                ID
            );
        }

        public void delete(long ID)
        {
            int count = m_db.SelectCount(@"select * from BillReportRepository where ID=@ID", ID);
            if (count == 0)
                throw new Exception("BillReportRepository.delete error. ID does not exists");

            m_db.Exec(@"delete from BillReportRepository where ID=@ID", ID);
        }

    }

    #endregion

    #region BillReportTemplate
    //**********************************************************
    //  BillReportTemplate
    //**********************************************************
    CMD_BillReportTemplate m_BillReportTemplate = null;
    public CMD_BillReportTemplate BillReportTemplate
    {
        get
        {
            if (m_BillReportTemplate == null)
                m_BillReportTemplate = new CMD_BillReportTemplate(this);
            return m_BillReportTemplate;
        }
    }

    [Serializable]
    public class TBL_BillReportTemplate
    {
        public long ID { get; set; }
        public string ReportName { get; set; }
        public string ReportPath { get; set; }
        public string RenderFormat { get; set; }
        public string ReportFileExt { get; set; }
        public string ContentType { get; set; }
        public string DatasetName { get; set; }
        public string StoredProcName { get; set; }
        public string ParameterType { get; set; }
        public int ReportStatus { get; set; }
        public string BillType { get; set; }
        public string IgnoreColumns { get; set; }

        public TBL_BillReportTemplate()
        {
            this.ID = 0;
            this.ReportName = "";
            this.ReportPath = "";
            this.RenderFormat = "";
            this.ReportFileExt = "";
            this.ContentType = "";
            this.DatasetName = "";
            this.StoredProcName = "";
            this.ParameterType = "";
            this.ReportStatus = 0;
            this.BillType = "";
            this.IgnoreColumns = "";
        }

        public TBL_BillReportTemplate(long ID, string ReportName, string ReportPath, string RenderFormat, string ReportFileExt, string ContentType, string DatasetName, string StoredProcName, string ParameterType, int ReportStatus, string BillType, string IgnoreColumns)
        {
            this.ID = ID;
            this.ReportName = ReportName;
            this.ReportPath = ReportPath;
            this.RenderFormat = RenderFormat;
            this.ReportFileExt = ReportFileExt;
            this.ContentType = ContentType;
            this.DatasetName = DatasetName;
            this.StoredProcName = StoredProcName;
            this.ParameterType = ParameterType;
            this.ReportStatus = ReportStatus;
            this.BillType = BillType;
            this.IgnoreColumns = IgnoreColumns;
        }

        public void CopyTo(ref TBL_BillReportTemplate to)
        {
            to.ID = this.ID;
            to.ReportName = this.ReportName;
            to.ReportPath = this.ReportPath;
            to.RenderFormat = this.RenderFormat;
            to.ReportFileExt = this.ReportFileExt;
            to.ContentType = this.ContentType;
            to.DatasetName = this.DatasetName;
            to.StoredProcName = this.StoredProcName;
            to.ParameterType = this.ParameterType;
            to.ReportStatus = this.ReportStatus;
            to.BillType = this.BillType;
            to.IgnoreColumns = this.IgnoreColumns;
        }

        public bool IsSame(TBL_BillReportTemplate x)
        {
            return (
                this.ID == x.ID &&
                this.ReportName == x.ReportName &&
                this.ReportPath == x.ReportPath &&
                this.RenderFormat == x.RenderFormat &&
                this.ReportFileExt == x.ReportFileExt &&
                this.ContentType == x.ContentType &&
                this.DatasetName == x.DatasetName &&
                this.StoredProcName == x.StoredProcName &&
                this.ParameterType == x.ParameterType &&
                this.ReportStatus == x.ReportStatus &&
                this.BillType == x.BillType &&
                this.IgnoreColumns == x.IgnoreColumns
            );
        }

        public static TBL_BillReportTemplate ReadRow(DataRow row)
        {
            TBL_BillReportTemplate record = new TBL_BillReportTemplate();
            record.ID = get_long_value(row["ID"]);
            record.ReportName = get_string_value(row["ReportName"]);
            record.ReportPath = get_string_value(row["ReportPath"]);
            record.RenderFormat = get_string_value(row["RenderFormat"]);
            record.ReportFileExt = get_string_value(row["ReportFileExt"]);
            record.ContentType = get_string_value(row["ContentType"]);
            record.DatasetName = get_string_value(row["DatasetName"]);
            record.StoredProcName = get_string_value(row["StoredProcName"]);
            record.ParameterType = get_string_value(row["ParameterType"]);
            record.ReportStatus = get_int_value(row["ReportStatus"]);
            record.BillType = get_string_value(row["BillType"]);
            record.IgnoreColumns = get_string_value(row["IgnoreColumns"]);
            return record;
        }

        public static List<TBL_BillReportTemplate> ReadTable(DataTable dt)
        {
            List<TBL_BillReportTemplate> records = new List<TBL_BillReportTemplate>();
            foreach (DataRow row in dt.Rows)
                records.Add(ReadRow(row));
            return records;
        }
    }

    public class CMD_BillReportTemplate
    {
        private MyLib.DAL_MSSQL m_db = null;

        public CMD_BillReportTemplate(MyLib.DAL_MSSQL db)
        {
            m_db = db;
        }

        public DataTable select(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select ID, ReportName, ReportPath, RenderFormat, ReportFileExt, ContentType, DatasetName, StoredProcName, ParameterType, ReportStatus, BillType, IgnoreColumns
					from BillReportTemplate
					" + where_clause, inputs);
        }

        public DataTable select()
        {
            return select("");
        }

        public DataTable selectPK(long ID)
        {
            return select(@"where ID=@ID"
                , ID);
        }

        public TBL_BillReportTemplate select2(string where_clause, params object[] inputs)
        {
            DataTable dt = select(where_clause, inputs);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_BillReportTemplate.ReadRow(dt.Rows[0]);
        }

        public TBL_BillReportTemplate selectPK2(long ID)
        {
            DataTable dt = selectPK(ID);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_BillReportTemplate.ReadRow(dt.Rows[0]);
        }

        public DataTable select_join(long ID)
        {
            return select_join("where BillReportTemplate.ID=@ID", ID);
        }

        public DataTable select_join()
        {
            return select_join("");
        }

        public DataTable select_join(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select BillReportTemplate.ID, BillReportTemplate.ReportName, BillReportTemplate.ReportPath, BillReportTemplate.RenderFormat, BillReportTemplate.ReportFileExt, BillReportTemplate.ContentType, BillReportTemplate.DatasetName, BillReportTemplate.StoredProcName, BillReportTemplate.ParameterType, BillReportTemplate.ReportStatus, BillReportTemplate.BillType, BillReportTemplate.IgnoreColumns
					from BillReportTemplate
					" + where_clause, inputs);
        }

        public void insert
        (
            ref long? ID,
            string ReportName,
            string ReportPath,
            string RenderFormat,
            string ReportFileExt,
            string ContentType,
            string DatasetName,
            string StoredProcName,
            string ParameterType,
            int? ReportStatus,
            string BillType,
            string IgnoreColumns
        )
        {
            ID = m_db.SelectInt("select isnull(MAX(ID), 0) + 1 from BillReportTemplate");

            m_db.Exec(@"
					insert into BillReportTemplate(
						ID,
						ReportName,
						ReportPath,
						RenderFormat,
						ReportFileExt,
						ContentType,
						DatasetName,
						StoredProcName,
						ParameterType,
						ReportStatus,
						BillType,
						IgnoreColumns
						)
					values(
						@ID,
						@ReportName,
						@ReportPath,
						@RenderFormat,
						@ReportFileExt,
						@ContentType,
						@DatasetName,
						@StoredProcName,
						@ParameterType,
						@ReportStatus,
						@BillType,
						@IgnoreColumns
						)
					", ID, ReportName, ReportPath, RenderFormat, ReportFileExt, ContentType, DatasetName, StoredProcName, ParameterType, ReportStatus, BillType, IgnoreColumns);

        }

        public void insert
        (
            long? ID,
            string ReportName,
            string ReportPath,
            string RenderFormat,
            string ReportFileExt,
            string ContentType,
            string DatasetName,
            string StoredProcName,
            string ParameterType,
            int? ReportStatus,
            string BillType,
            string IgnoreColumns
        )
        {
            int count = m_db.SelectCount(@"select * from BillReportTemplate where ID=@ID", ID);
            if (count > 0)
                throw new Exception("BillReportTemplate.insert error. ID duplicate");

            m_db.Exec(@"
					insert into BillReportTemplate(
						ID,
						ReportName,
						ReportPath,
						RenderFormat,
						ReportFileExt,
						ContentType,
						DatasetName,
						StoredProcName,
						ParameterType,
						ReportStatus,
						BillType,
						IgnoreColumns
						)
					values(
						@ID,
						@ReportName,
						@ReportPath,
						@RenderFormat,
						@ReportFileExt,
						@ContentType,
						@DatasetName,
						@StoredProcName,
						@ParameterType,
						@ReportStatus,
						@BillType,
						@IgnoreColumns
						)
					", ID, ReportName, ReportPath, RenderFormat, ReportFileExt, ContentType, DatasetName, StoredProcName, ParameterType, ReportStatus, BillType, IgnoreColumns);
        }

        public void update
        (
            long _old_ID,
            long _new_ID,
            string ReportName,
            string ReportPath,
            string RenderFormat,
            string ReportFileExt,
            string ContentType,
            string DatasetName,
            string StoredProcName,
            string ParameterType,
            int? ReportStatus,
            string BillType,
            string IgnoreColumns
        )
        {
            int count = m_db.SelectCount(@"select * from BillReportTemplate where ID=@_old_ID", _old_ID);
            if (count == 0)
                throw new Exception("BillReportTemplate.update error. ID does not exists");

            m_db.Exec(@"
					update BillReportTemplate
					set
						ID = @_new_ID,
						ReportName = @ReportName,
						ReportPath = @ReportPath,
						RenderFormat = @RenderFormat,
						ReportFileExt = @ReportFileExt,
						ContentType = @ContentType,
						DatasetName = @DatasetName,
						StoredProcName = @StoredProcName,
						ParameterType = @ParameterType,
						ReportStatus = @ReportStatus,
						BillType = @BillType,
						IgnoreColumns = @IgnoreColumns
					where ID=@_old_ID
					",
                _new_ID,
                ReportName,
                ReportPath,
                RenderFormat,
                ReportFileExt,
                ContentType,
                DatasetName,
                StoredProcName,
                ParameterType,
                ReportStatus,
                BillType,
                IgnoreColumns,
                _old_ID
            );
        }

        public void delete(long ID)
        {
            int count = m_db.SelectCount(@"select * from BillReportTemplate where ID=@ID", ID);
            if (count == 0)
                throw new Exception("BillReportTemplate.delete error. ID does not exists");

            m_db.Exec(@"delete from BillReportTemplate where ID=@ID", ID);
        }

    }

    #endregion

    #region BillReportUserGroup
    //**********************************************************
    //  BillReportUserGroup
    //**********************************************************
    CMD_BillReportUserGroup m_BillReportUserGroup = null;
    public CMD_BillReportUserGroup BillReportUserGroup
    {
        get
        {
            if (m_BillReportUserGroup == null)
                m_BillReportUserGroup = new CMD_BillReportUserGroup(this);
            return m_BillReportUserGroup;
        }
    }

    [Serializable]
    public class TBL_BillReportUserGroup
    {
        public long ID { get; set; }
        public long BillReportTemplateID { get; set; }
        public long GroupMemberID { get; set; }

        public TBL_BillReportUserGroup()
        {
            this.ID = 0;
            this.BillReportTemplateID = 0;
            this.GroupMemberID = 0;
        }

        public TBL_BillReportUserGroup(long ID, long BillReportTemplateID, long GroupMemberID)
        {
            this.ID = ID;
            this.BillReportTemplateID = BillReportTemplateID;
            this.GroupMemberID = GroupMemberID;
        }

        public void CopyTo(ref TBL_BillReportUserGroup to)
        {
            to.ID = this.ID;
            to.BillReportTemplateID = this.BillReportTemplateID;
            to.GroupMemberID = this.GroupMemberID;
        }

        public bool IsSame(TBL_BillReportUserGroup x)
        {
            return (
                this.ID == x.ID &&
                this.BillReportTemplateID == x.BillReportTemplateID &&
                this.GroupMemberID == x.GroupMemberID
            );
        }

        public static TBL_BillReportUserGroup ReadRow(DataRow row)
        {
            TBL_BillReportUserGroup record = new TBL_BillReportUserGroup();
            record.ID = get_long_value(row["ID"]);
            record.BillReportTemplateID = get_long_value(row["BillReportTemplateID"]);
            record.GroupMemberID = get_long_value(row["GroupMemberID"]);
            return record;
        }

        public static List<TBL_BillReportUserGroup> ReadTable(DataTable dt)
        {
            List<TBL_BillReportUserGroup> records = new List<TBL_BillReportUserGroup>();
            foreach (DataRow row in dt.Rows)
                records.Add(ReadRow(row));
            return records;
        }
    }

    public class CMD_BillReportUserGroup
    {
        private MyLib.DAL_MSSQL m_db = null;

        public CMD_BillReportUserGroup(MyLib.DAL_MSSQL db)
        {
            m_db = db;
        }

        public DataTable select(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select ID, BillReportTemplateID, GroupMemberID
					from BillReportUserGroup
					" + where_clause, inputs);
        }

        public DataTable select()
        {
            return select("");
        }

        public DataTable selectPK(long ID)
        {
            return select(@"where ID=@ID"
                , ID);
        }

        public TBL_BillReportUserGroup select2(string where_clause, params object[] inputs)
        {
            DataTable dt = select(where_clause, inputs);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_BillReportUserGroup.ReadRow(dt.Rows[0]);
        }

        public TBL_BillReportUserGroup selectPK2(long ID)
        {
            DataTable dt = selectPK(ID);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_BillReportUserGroup.ReadRow(dt.Rows[0]);
        }

        public DataTable select_join(long ID)
        {
            return select_join("where BillReportUserGroup.ID=@ID", ID);
        }

        public DataTable select_join()
        {
            return select_join("");
        }

        public DataTable select_join(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select BillReportUserGroup.ID, BillReportUserGroup.BillReportTemplateID, BillReportUserGroup.GroupMemberID
					from BillReportUserGroup
					" + where_clause, inputs);
        }

        public void insert
        (
            ref long? ID,
            long? BillReportTemplateID,
            long? GroupMemberID
        )
        {

            m_db.Exec(@"
					insert into BillReportUserGroup(
						BillReportTemplateID,
						GroupMemberID
						)
					values(
						@BillReportTemplateID,
						@GroupMemberID
						)
					", BillReportTemplateID, GroupMemberID);

            ID = m_db.SelectInt("select IDENT_CURRENT('BillReportUserGroup')");
        }

        public void insert
        (
            long? BillReportTemplateID,
            long? GroupMemberID
        )
        {
            m_db.Exec(@"
					insert into BillReportUserGroup(
						BillReportTemplateID,
						GroupMemberID
						)
					values(
						@BillReportTemplateID,
						@GroupMemberID
						)
					", BillReportTemplateID, GroupMemberID);
        }

        public void update
        (
            long ID,
            long? BillReportTemplateID,
            long? GroupMemberID
        )
        {
            int count = m_db.SelectCount(@"select * from BillReportUserGroup where ID=@ID", ID);
            if (count == 0)
                throw new Exception("BillReportUserGroup.update error. ID does not exists");

            m_db.Exec(@"
					update BillReportUserGroup
					set
						BillReportTemplateID = @BillReportTemplateID,
						GroupMemberID = @GroupMemberID
					where ID=@ID
					",
                BillReportTemplateID,
                GroupMemberID,
                ID
            );
        }

        public void delete(long ID)
        {
            int count = m_db.SelectCount(@"select * from BillReportUserGroup where ID=@ID", ID);
            if (count == 0)
                throw new Exception("BillReportUserGroup.delete error. ID does not exists");

            m_db.Exec(@"delete from BillReportUserGroup where ID=@ID", ID);
        }

    }

    #endregion

    #region ChangeRequest
    //**********************************************************
    //  ChangeRequest
    //**********************************************************
    CMD_ChangeRequest m_ChangeRequest = null;
    public CMD_ChangeRequest ChangeRequest
    {
        get
        {
            if (m_ChangeRequest == null)
                m_ChangeRequest = new CMD_ChangeRequest(this);
            return m_ChangeRequest;
        }
    }

    [Serializable]
    public class TBL_ChangeRequest
    {
        public long ID { get; set; }
        public string ChangeRequestNo { get; set; }
        public long ChangeRequestTypeID { get; set; }
        public long ChangeRequestStatus { get; set; }
        public string RequestorComment { get; set; }
        public long CreatedBy { get; set; }
        public DateTime CreatedDatetime { get; set; }
        public long ModifiedBy { get; set; }
        public DateTime ModifiedDatetime { get; set; }
        public int Version { get; set; }

        public TBL_ChangeRequest()
        {
            this.ID = 0;
            this.ChangeRequestNo = "";
            this.ChangeRequestTypeID = 0;
            this.ChangeRequestStatus = 0;
            this.RequestorComment = "";
            this.CreatedBy = 0;
            this.CreatedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
            this.ModifiedBy = 0;
            this.ModifiedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
            this.Version = 0;
        }

        public TBL_ChangeRequest(long ID, string ChangeRequestNo, long ChangeRequestTypeID, long ChangeRequestStatus, string RequestorComment, long CreatedBy, DateTime CreatedDatetime, long ModifiedBy, DateTime ModifiedDatetime, int Version)
        {
            this.ID = ID;
            this.ChangeRequestNo = ChangeRequestNo;
            this.ChangeRequestTypeID = ChangeRequestTypeID;
            this.ChangeRequestStatus = ChangeRequestStatus;
            this.RequestorComment = RequestorComment;
            this.CreatedBy = CreatedBy;
            this.CreatedDatetime = CreatedDatetime;
            this.ModifiedBy = ModifiedBy;
            this.ModifiedDatetime = ModifiedDatetime;
            this.Version = Version;
        }

        public void CopyTo(ref TBL_ChangeRequest to)
        {
            to.ID = this.ID;
            to.ChangeRequestNo = this.ChangeRequestNo;
            to.ChangeRequestTypeID = this.ChangeRequestTypeID;
            to.ChangeRequestStatus = this.ChangeRequestStatus;
            to.RequestorComment = this.RequestorComment;
            to.CreatedBy = this.CreatedBy;
            to.CreatedDatetime = this.CreatedDatetime;
            to.ModifiedBy = this.ModifiedBy;
            to.ModifiedDatetime = this.ModifiedDatetime;
            to.Version = this.Version;
        }

        public bool IsSame(TBL_ChangeRequest x)
        {
            return (
                this.ID == x.ID &&
                this.ChangeRequestNo == x.ChangeRequestNo &&
                this.ChangeRequestTypeID == x.ChangeRequestTypeID &&
                this.ChangeRequestStatus == x.ChangeRequestStatus &&
                this.RequestorComment == x.RequestorComment &&
                this.CreatedBy == x.CreatedBy &&
                this.CreatedDatetime == x.CreatedDatetime &&
                this.ModifiedBy == x.ModifiedBy &&
                this.ModifiedDatetime == x.ModifiedDatetime &&
                this.Version == x.Version
            );
        }

        public static TBL_ChangeRequest ReadRow(DataRow row)
        {
            TBL_ChangeRequest record = new TBL_ChangeRequest();
            record.ID = get_long_value(row["ID"]);
            record.ChangeRequestNo = get_string_value(row["ChangeRequestNo"]);
            record.ChangeRequestTypeID = get_long_value(row["ChangeRequestTypeID"]);
            record.ChangeRequestStatus = get_long_value(row["ChangeRequestStatus"]);
            record.RequestorComment = get_string_value(row["RequestorComment"]);
            record.CreatedBy = get_long_value(row["CreatedBy"]);
            record.CreatedDatetime = get_DateTime_value(row["CreatedDatetime"]);
            record.ModifiedBy = get_long_value(row["ModifiedBy"]);
            record.ModifiedDatetime = get_DateTime_value(row["ModifiedDatetime"]);
            record.Version = get_int_value(row["Version"]);
            return record;
        }

        public static List<TBL_ChangeRequest> ReadTable(DataTable dt)
        {
            List<TBL_ChangeRequest> records = new List<TBL_ChangeRequest>();
            foreach (DataRow row in dt.Rows)
                records.Add(ReadRow(row));
            return records;
        }
    }

    public class CMD_ChangeRequest
    {
        private MyLib.DAL_MSSQL m_db = null;

        public CMD_ChangeRequest(MyLib.DAL_MSSQL db)
        {
            m_db = db;
        }

        public DataTable select(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select ID, ChangeRequestNo, ChangeRequestTypeID, ChangeRequestStatus, RequestorComment, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDatetime, Version
					from ChangeRequest
					" + where_clause, inputs);
        }

        public DataTable select()
        {
            return select("");
        }

        public DataTable selectPK(long ID)
        {
            return select(@"where ID=@ID"
                , ID);
        }

        public TBL_ChangeRequest select2(string where_clause, params object[] inputs)
        {
            DataTable dt = select(where_clause, inputs);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_ChangeRequest.ReadRow(dt.Rows[0]);
        }

        public TBL_ChangeRequest selectPK2(long ID)
        {
            DataTable dt = selectPK(ID);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_ChangeRequest.ReadRow(dt.Rows[0]);
        }

        public DataTable select_join(long ID)
        {
            return select_join("where ChangeRequest.ID=@ID", ID);
        }

        public DataTable select_join()
        {
            return select_join("");
        }

        public DataTable select_join(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select ChangeRequest.ID, ChangeRequest.ChangeRequestNo, ChangeRequest.ChangeRequestTypeID, ChangeRequest.ChangeRequestStatus, ChangeRequest.RequestorComment, ChangeRequest.CreatedBy, ChangeRequest.CreatedDatetime, ChangeRequest.ModifiedBy, ChangeRequest.ModifiedDatetime, ChangeRequest.Version
					from ChangeRequest
					" + where_clause, inputs);
        }

        public void insert
        (
            ref long? ID,
            string ChangeRequestNo,
            long? ChangeRequestTypeID,
            long? ChangeRequestStatus,
            string RequestorComment,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDatetime,
            int? Version
        )
        {

            m_db.Exec(@"
					insert into ChangeRequest(
						ChangeRequestNo,
						ChangeRequestTypeID,
						ChangeRequestStatus,
						RequestorComment,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDatetime,
						Version
						)
					values(
						@ChangeRequestNo,
						@ChangeRequestTypeID,
						@ChangeRequestStatus,
						@RequestorComment,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDatetime,
						@Version
						)
					", ChangeRequestNo, ChangeRequestTypeID, ChangeRequestStatus, RequestorComment, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDatetime, Version);

            ID = m_db.SelectInt("select IDENT_CURRENT('ChangeRequest')");
        }

        public void insert
        (
            string ChangeRequestNo,
            long? ChangeRequestTypeID,
            long? ChangeRequestStatus,
            string RequestorComment,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDatetime,
            int? Version
        )
        {
            m_db.Exec(@"
					insert into ChangeRequest(
						ChangeRequestNo,
						ChangeRequestTypeID,
						ChangeRequestStatus,
						RequestorComment,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDatetime,
						Version
						)
					values(
						@ChangeRequestNo,
						@ChangeRequestTypeID,
						@ChangeRequestStatus,
						@RequestorComment,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDatetime,
						@Version
						)
					", ChangeRequestNo, ChangeRequestTypeID, ChangeRequestStatus, RequestorComment, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDatetime, Version);
        }

        public void update
        (
            long ID,
            string ChangeRequestNo,
            long? ChangeRequestTypeID,
            long? ChangeRequestStatus,
            string RequestorComment,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDatetime,
            int? Version
        )
        {
            int count = m_db.SelectCount(@"select * from ChangeRequest where ID=@ID", ID);
            if (count == 0)
                throw new Exception("ChangeRequest.update error. ID does not exists");

            m_db.Exec(@"
					update ChangeRequest
					set
						ChangeRequestNo = @ChangeRequestNo,
						ChangeRequestTypeID = @ChangeRequestTypeID,
						ChangeRequestStatus = @ChangeRequestStatus,
						RequestorComment = @RequestorComment,
						CreatedBy = @CreatedBy,
						CreatedDatetime = @CreatedDatetime,
						ModifiedBy = @ModifiedBy,
						ModifiedDatetime = @ModifiedDatetime,
						Version = @Version
					where ID=@ID
					",
                ChangeRequestNo,
                ChangeRequestTypeID,
                ChangeRequestStatus,
                RequestorComment,
                CreatedBy,
                CreatedDatetime,
                ModifiedBy,
                ModifiedDatetime,
                Version,
                ID
            );
        }

        public void delete(long ID)
        {
            int count = m_db.SelectCount(@"select * from ChangeRequest where ID=@ID", ID);
            if (count == 0)
                throw new Exception("ChangeRequest.delete error. ID does not exists");

            m_db.Exec(@"delete from ChangeRequest where ID=@ID", ID);
        }

    }

    #endregion

    #region ChangeRequestRoleGroup
    //**********************************************************
    //  ChangeRequestRoleGroup
    //**********************************************************
    CMD_ChangeRequestRoleGroup m_ChangeRequestRoleGroup = null;
    public CMD_ChangeRequestRoleGroup ChangeRequestRoleGroup
    {
        get
        {
            if (m_ChangeRequestRoleGroup == null)
                m_ChangeRequestRoleGroup = new CMD_ChangeRequestRoleGroup(this);
            return m_ChangeRequestRoleGroup;
        }
    }

    [Serializable]
    public class TBL_ChangeRequestRoleGroup
    {
        public long ID { get; set; }
        public long ChangeRequestRoleID { get; set; }
        public long GroupMemberID { get; set; }
        public DateTime CreatedBy { get; set; }
        public DateTime CreatedDatetime { get; set; }
        public long ModifiedBy { get; set; }
        public DateTime ModifiedDatetime { get; set; }

        public TBL_ChangeRequestRoleGroup()
        {
            this.ID = 0;
            this.ChangeRequestRoleID = 0;
            this.GroupMemberID = 0;
            this.CreatedBy = Convert.ToDateTime("1900-01-01 00:00:00");
            this.CreatedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
            this.ModifiedBy = 0;
            this.ModifiedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
        }

        public TBL_ChangeRequestRoleGroup(long ID, long ChangeRequestRoleID, long GroupMemberID, DateTime CreatedBy, DateTime CreatedDatetime, long ModifiedBy, DateTime ModifiedDatetime)
        {
            this.ID = ID;
            this.ChangeRequestRoleID = ChangeRequestRoleID;
            this.GroupMemberID = GroupMemberID;
            this.CreatedBy = CreatedBy;
            this.CreatedDatetime = CreatedDatetime;
            this.ModifiedBy = ModifiedBy;
            this.ModifiedDatetime = ModifiedDatetime;
        }

        public void CopyTo(ref TBL_ChangeRequestRoleGroup to)
        {
            to.ID = this.ID;
            to.ChangeRequestRoleID = this.ChangeRequestRoleID;
            to.GroupMemberID = this.GroupMemberID;
            to.CreatedBy = this.CreatedBy;
            to.CreatedDatetime = this.CreatedDatetime;
            to.ModifiedBy = this.ModifiedBy;
            to.ModifiedDatetime = this.ModifiedDatetime;
        }

        public bool IsSame(TBL_ChangeRequestRoleGroup x)
        {
            return (
                this.ID == x.ID &&
                this.ChangeRequestRoleID == x.ChangeRequestRoleID &&
                this.GroupMemberID == x.GroupMemberID &&
                this.CreatedBy == x.CreatedBy &&
                this.CreatedDatetime == x.CreatedDatetime &&
                this.ModifiedBy == x.ModifiedBy &&
                this.ModifiedDatetime == x.ModifiedDatetime
            );
        }

        public static TBL_ChangeRequestRoleGroup ReadRow(DataRow row)
        {
            TBL_ChangeRequestRoleGroup record = new TBL_ChangeRequestRoleGroup();
            record.ID = get_long_value(row["ID"]);
            record.ChangeRequestRoleID = get_long_value(row["ChangeRequestRoleID"]);
            record.GroupMemberID = get_long_value(row["GroupMemberID"]);
            record.CreatedBy = get_DateTime_value(row["CreatedBy"]);
            record.CreatedDatetime = get_DateTime_value(row["CreatedDatetime"]);
            record.ModifiedBy = get_long_value(row["ModifiedBy"]);
            record.ModifiedDatetime = get_DateTime_value(row["ModifiedDatetime"]);
            return record;
        }

        public static List<TBL_ChangeRequestRoleGroup> ReadTable(DataTable dt)
        {
            List<TBL_ChangeRequestRoleGroup> records = new List<TBL_ChangeRequestRoleGroup>();
            foreach (DataRow row in dt.Rows)
                records.Add(ReadRow(row));
            return records;
        }
    }

    public class CMD_ChangeRequestRoleGroup
    {
        private MyLib.DAL_MSSQL m_db = null;

        public CMD_ChangeRequestRoleGroup(MyLib.DAL_MSSQL db)
        {
            m_db = db;
        }

        public DataTable select(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select ID, ChangeRequestRoleID, GroupMemberID, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDatetime
					from ChangeRequestRoleGroup
					" + where_clause, inputs);
        }

        public DataTable select()
        {
            return select("");
        }

        public DataTable selectPK(long ID)
        {
            return select(@"where ID=@ID"
                , ID);
        }

        public TBL_ChangeRequestRoleGroup select2(string where_clause, params object[] inputs)
        {
            DataTable dt = select(where_clause, inputs);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_ChangeRequestRoleGroup.ReadRow(dt.Rows[0]);
        }

        public TBL_ChangeRequestRoleGroup selectPK2(long ID)
        {
            DataTable dt = selectPK(ID);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_ChangeRequestRoleGroup.ReadRow(dt.Rows[0]);
        }

        public DataTable select_join(long ID)
        {
            return select_join("where ChangeRequestRoleGroup.ID=@ID", ID);
        }

        public DataTable select_join()
        {
            return select_join("");
        }

        public DataTable select_join(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select ChangeRequestRoleGroup.ID, ChangeRequestRoleGroup.ChangeRequestRoleID, ChangeRequestRoleGroup.GroupMemberID, ChangeRequestRoleGroup.CreatedBy, ChangeRequestRoleGroup.CreatedDatetime, ChangeRequestRoleGroup.ModifiedBy, ChangeRequestRoleGroup.ModifiedDatetime
					from ChangeRequestRoleGroup
					" + where_clause, inputs);
        }

        public void insert
        (
            ref long? ID,
            long? ChangeRequestRoleID,
            long? GroupMemberID,
            DateTime? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDatetime
        )
        {

            m_db.Exec(@"
					insert into ChangeRequestRoleGroup(
						ChangeRequestRoleID,
						GroupMemberID,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDatetime
						)
					values(
						@ChangeRequestRoleID,
						@GroupMemberID,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDatetime
						)
					", ChangeRequestRoleID, GroupMemberID, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDatetime);

            ID = m_db.SelectInt("select IDENT_CURRENT('ChangeRequestRoleGroup')");
        }

        public void insert
        (
            long? ChangeRequestRoleID,
            long? GroupMemberID,
            DateTime? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDatetime
        )
        {
            m_db.Exec(@"
					insert into ChangeRequestRoleGroup(
						ChangeRequestRoleID,
						GroupMemberID,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDatetime
						)
					values(
						@ChangeRequestRoleID,
						@GroupMemberID,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDatetime
						)
					", ChangeRequestRoleID, GroupMemberID, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDatetime);
        }

        public void update
        (
            long ID,
            long? ChangeRequestRoleID,
            long? GroupMemberID,
            DateTime? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDatetime
        )
        {
            int count = m_db.SelectCount(@"select * from ChangeRequestRoleGroup where ID=@ID", ID);
            if (count == 0)
                throw new Exception("ChangeRequestRoleGroup.update error. ID does not exists");

            m_db.Exec(@"
					update ChangeRequestRoleGroup
					set
						ChangeRequestRoleID = @ChangeRequestRoleID,
						GroupMemberID = @GroupMemberID,
						CreatedBy = @CreatedBy,
						CreatedDatetime = @CreatedDatetime,
						ModifiedBy = @ModifiedBy,
						ModifiedDatetime = @ModifiedDatetime
					where ID=@ID
					",
                ChangeRequestRoleID,
                GroupMemberID,
                CreatedBy,
                CreatedDatetime,
                ModifiedBy,
                ModifiedDatetime,
                ID
            );
        }

        public void delete(long ID)
        {
            int count = m_db.SelectCount(@"select * from ChangeRequestRoleGroup where ID=@ID", ID);
            if (count == 0)
                throw new Exception("ChangeRequestRoleGroup.delete error. ID does not exists");

            m_db.Exec(@"delete from ChangeRequestRoleGroup where ID=@ID", ID);
        }

    }

    #endregion

    #region ChangeRequestStatus
    //**********************************************************
    //  ChangeRequestStatus
    //**********************************************************
    CMD_ChangeRequestStatus m_ChangeRequestStatus = null;
    public CMD_ChangeRequestStatus ChangeRequestStatus
    {
        get
        {
            if (m_ChangeRequestStatus == null)
                m_ChangeRequestStatus = new CMD_ChangeRequestStatus(this);
            return m_ChangeRequestStatus;
        }
    }

    [Serializable]
    public class TBL_ChangeRequestStatus
    {
        public long ID { get; set; }
        public string StatusName { get; set; }

        public TBL_ChangeRequestStatus()
        {
            this.ID = 0;
            this.StatusName = "";
        }

        public TBL_ChangeRequestStatus(long ID, string StatusName)
        {
            this.ID = ID;
            this.StatusName = StatusName;
        }

        public void CopyTo(ref TBL_ChangeRequestStatus to)
        {
            to.ID = this.ID;
            to.StatusName = this.StatusName;
        }

        public bool IsSame(TBL_ChangeRequestStatus x)
        {
            return (
                this.ID == x.ID &&
                this.StatusName == x.StatusName
            );
        }

        public static TBL_ChangeRequestStatus ReadRow(DataRow row)
        {
            TBL_ChangeRequestStatus record = new TBL_ChangeRequestStatus();
            record.ID = get_long_value(row["ID"]);
            record.StatusName = get_string_value(row["StatusName"]);
            return record;
        }

        public static List<TBL_ChangeRequestStatus> ReadTable(DataTable dt)
        {
            List<TBL_ChangeRequestStatus> records = new List<TBL_ChangeRequestStatus>();
            foreach (DataRow row in dt.Rows)
                records.Add(ReadRow(row));
            return records;
        }
    }

    public class CMD_ChangeRequestStatus
    {
        private MyLib.DAL_MSSQL m_db = null;

        public CMD_ChangeRequestStatus(MyLib.DAL_MSSQL db)
        {
            m_db = db;
        }

        public DataTable select(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select ID, StatusName
					from ChangeRequestStatus
					" + where_clause, inputs);
        }

        public DataTable select()
        {
            return select("");
        }

        public DataTable selectPK(long ID)
        {
            return select(@"where ID=@ID"
                , ID);
        }

        public TBL_ChangeRequestStatus select2(string where_clause, params object[] inputs)
        {
            DataTable dt = select(where_clause, inputs);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_ChangeRequestStatus.ReadRow(dt.Rows[0]);
        }

        public TBL_ChangeRequestStatus selectPK2(long ID)
        {
            DataTable dt = selectPK(ID);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_ChangeRequestStatus.ReadRow(dt.Rows[0]);
        }

        public DataTable select_join(long ID)
        {
            return select_join("where ChangeRequestStatus.ID=@ID", ID);
        }

        public DataTable select_join()
        {
            return select_join("");
        }

        public DataTable select_join(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select ChangeRequestStatus.ID, ChangeRequestStatus.StatusName
					from ChangeRequestStatus
					" + where_clause, inputs);
        }

        public void insert
        (
            ref long? ID,
            string StatusName
        )
        {
            ID = m_db.SelectInt("select isnull(MAX(ID), 0) + 1 from ChangeRequestStatus");

            m_db.Exec(@"
					insert into ChangeRequestStatus(
						ID,
						StatusName
						)
					values(
						@ID,
						@StatusName
						)
					", ID, StatusName);

        }

        public void insert
        (
            long? ID,
            string StatusName
        )
        {
            int count = m_db.SelectCount(@"select * from ChangeRequestStatus where ID=@ID", ID);
            if (count > 0)
                throw new Exception("ChangeRequestStatus.insert error. ID duplicate");

            m_db.Exec(@"
					insert into ChangeRequestStatus(
						ID,
						StatusName
						)
					values(
						@ID,
						@StatusName
						)
					", ID, StatusName);
        }

        public void update
        (
            long _old_ID,
            long _new_ID,
            string StatusName
        )
        {
            int count = m_db.SelectCount(@"select * from ChangeRequestStatus where ID=@_old_ID", _old_ID);
            if (count == 0)
                throw new Exception("ChangeRequestStatus.update error. ID does not exists");

            m_db.Exec(@"
					update ChangeRequestStatus
					set
						ID = @_new_ID,
						StatusName = @StatusName
					where ID=@_old_ID
					",
                _new_ID,
                StatusName,
                _old_ID
            );
        }

        public void delete(long ID)
        {
            int count = m_db.SelectCount(@"select * from ChangeRequestStatus where ID=@ID", ID);
            if (count == 0)
                throw new Exception("ChangeRequestStatus.delete error. ID does not exists");

            m_db.Exec(@"delete from ChangeRequestStatus where ID=@ID", ID);
        }

    }

    #endregion

    #region ChangeRequestType
    //**********************************************************
    //  ChangeRequestType
    //**********************************************************
    CMD_ChangeRequestType m_ChangeRequestType = null;
    public CMD_ChangeRequestType ChangeRequestType
    {
        get
        {
            if (m_ChangeRequestType == null)
                m_ChangeRequestType = new CMD_ChangeRequestType(this);
            return m_ChangeRequestType;
        }
    }

    [Serializable]
    public class TBL_ChangeRequestType
    {
        public long ID { get; set; }
        public string ChangeRequestType { get; set; }

        public TBL_ChangeRequestType()
        {
            this.ID = 0;
            this.ChangeRequestType = "";
        }

        public TBL_ChangeRequestType(long ID, string ChangeRequestType)
        {
            this.ID = ID;
            this.ChangeRequestType = ChangeRequestType;
        }

        public void CopyTo(ref TBL_ChangeRequestType to)
        {
            to.ID = this.ID;
            to.ChangeRequestType = this.ChangeRequestType;
        }

        public bool IsSame(TBL_ChangeRequestType x)
        {
            return (
                this.ID == x.ID &&
                this.ChangeRequestType == x.ChangeRequestType
            );
        }

        public static TBL_ChangeRequestType ReadRow(DataRow row)
        {
            TBL_ChangeRequestType record = new TBL_ChangeRequestType();
            record.ID = get_long_value(row["ID"]);
            record.ChangeRequestType = get_string_value(row["ChangeRequestType"]);
            return record;
        }

        public static List<TBL_ChangeRequestType> ReadTable(DataTable dt)
        {
            List<TBL_ChangeRequestType> records = new List<TBL_ChangeRequestType>();
            foreach (DataRow row in dt.Rows)
                records.Add(ReadRow(row));
            return records;
        }
    }

    public class CMD_ChangeRequestType
    {
        private MyLib.DAL_MSSQL m_db = null;

        public CMD_ChangeRequestType(MyLib.DAL_MSSQL db)
        {
            m_db = db;
        }

        public DataTable select(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select ID, ChangeRequestType
					from ChangeRequestType
					" + where_clause, inputs);
        }

        public DataTable select()
        {
            return select("");
        }

        public DataTable selectPK(long ID)
        {
            return select(@"where ID=@ID"
                , ID);
        }

        public TBL_ChangeRequestType select2(string where_clause, params object[] inputs)
        {
            DataTable dt = select(where_clause, inputs);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_ChangeRequestType.ReadRow(dt.Rows[0]);
        }

        public TBL_ChangeRequestType selectPK2(long ID)
        {
            DataTable dt = selectPK(ID);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_ChangeRequestType.ReadRow(dt.Rows[0]);
        }

        public DataTable select_join(long ID)
        {
            return select_join("where ChangeRequestType.ID=@ID", ID);
        }

        public DataTable select_join()
        {
            return select_join("");
        }

        public DataTable select_join(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select ChangeRequestType.ID, ChangeRequestType.ChangeRequestType
					from ChangeRequestType
					" + where_clause, inputs);
        }

        public void insert
        (
            ref long? ID,
            string ChangeRequestType
        )
        {
            ID = m_db.SelectInt("select isnull(MAX(ID), 0) + 1 from ChangeRequestType");

            m_db.Exec(@"
					insert into ChangeRequestType(
						ID,
						ChangeRequestType
						)
					values(
						@ID,
						@ChangeRequestType
						)
					", ID, ChangeRequestType);

        }

        public void insert
        (
            long? ID,
            string ChangeRequestType
        )
        {
            int count = m_db.SelectCount(@"select * from ChangeRequestType where ID=@ID", ID);
            if (count > 0)
                throw new Exception("ChangeRequestType.insert error. ID duplicate");

            m_db.Exec(@"
					insert into ChangeRequestType(
						ID,
						ChangeRequestType
						)
					values(
						@ID,
						@ChangeRequestType
						)
					", ID, ChangeRequestType);
        }

        public void update
        (
            long _old_ID,
            long _new_ID,
            string ChangeRequestType
        )
        {
            int count = m_db.SelectCount(@"select * from ChangeRequestType where ID=@_old_ID", _old_ID);
            if (count == 0)
                throw new Exception("ChangeRequestType.update error. ID does not exists");

            m_db.Exec(@"
					update ChangeRequestType
					set
						ID = @_new_ID,
						ChangeRequestType = @ChangeRequestType
					where ID=@_old_ID
					",
                _new_ID,
                ChangeRequestType,
                _old_ID
            );
        }

        public void delete(long ID)
        {
            int count = m_db.SelectCount(@"select * from ChangeRequestType where ID=@ID", ID);
            if (count == 0)
                throw new Exception("ChangeRequestType.delete error. ID does not exists");

            m_db.Exec(@"delete from ChangeRequestType where ID=@ID", ID);
        }

    }

    #endregion

    #region Configuration
    //**********************************************************
    //  Configuration
    //**********************************************************
    CMD_Configuration m_Configuration = null;
    public CMD_Configuration Configuration
    {
        get
        {
            if (m_Configuration == null)
                m_Configuration = new CMD_Configuration(this);
            return m_Configuration;
        }
    }

    [Serializable]
    public class TBL_Configuration
    {
        public long ID { get; set; }
        public string ConfigurationName { get; set; }
        public string ConfigurationValue { get; set; }
        public long CreatedBy { get; set; }
        public DateTime CreatedDatetime { get; set; }
        public long ModifiedBy { get; set; }
        public DateTime ModifiedDatetime { get; set; }

        public TBL_Configuration()
        {
            this.ID = 0;
            this.ConfigurationName = "";
            this.ConfigurationValue = "";
            this.CreatedBy = 0;
            this.CreatedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
            this.ModifiedBy = 0;
            this.ModifiedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
        }

        public TBL_Configuration(long ID, string ConfigurationName, string ConfigurationValue, long CreatedBy, DateTime CreatedDatetime, long ModifiedBy, DateTime ModifiedDatetime)
        {
            this.ID = ID;
            this.ConfigurationName = ConfigurationName;
            this.ConfigurationValue = ConfigurationValue;
            this.CreatedBy = CreatedBy;
            this.CreatedDatetime = CreatedDatetime;
            this.ModifiedBy = ModifiedBy;
            this.ModifiedDatetime = ModifiedDatetime;
        }

        public void CopyTo(ref TBL_Configuration to)
        {
            to.ID = this.ID;
            to.ConfigurationName = this.ConfigurationName;
            to.ConfigurationValue = this.ConfigurationValue;
            to.CreatedBy = this.CreatedBy;
            to.CreatedDatetime = this.CreatedDatetime;
            to.ModifiedBy = this.ModifiedBy;
            to.ModifiedDatetime = this.ModifiedDatetime;
        }

        public bool IsSame(TBL_Configuration x)
        {
            return (
                this.ID == x.ID &&
                this.ConfigurationName == x.ConfigurationName &&
                this.ConfigurationValue == x.ConfigurationValue &&
                this.CreatedBy == x.CreatedBy &&
                this.CreatedDatetime == x.CreatedDatetime &&
                this.ModifiedBy == x.ModifiedBy &&
                this.ModifiedDatetime == x.ModifiedDatetime
            );
        }

        public static TBL_Configuration ReadRow(DataRow row)
        {
            TBL_Configuration record = new TBL_Configuration();
            record.ID = get_long_value(row["ID"]);
            record.ConfigurationName = get_string_value(row["ConfigurationName"]);
            record.ConfigurationValue = get_string_value(row["ConfigurationValue"]);
            record.CreatedBy = get_long_value(row["CreatedBy"]);
            record.CreatedDatetime = get_DateTime_value(row["CreatedDatetime"]);
            record.ModifiedBy = get_long_value(row["ModifiedBy"]);
            record.ModifiedDatetime = get_DateTime_value(row["ModifiedDatetime"]);
            return record;
        }

        public static List<TBL_Configuration> ReadTable(DataTable dt)
        {
            List<TBL_Configuration> records = new List<TBL_Configuration>();
            foreach (DataRow row in dt.Rows)
                records.Add(ReadRow(row));
            return records;
        }
    }

    public class CMD_Configuration
    {
        private MyLib.DAL_MSSQL m_db = null;

        public CMD_Configuration(MyLib.DAL_MSSQL db)
        {
            m_db = db;
        }

        public DataTable select(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select ID, ConfigurationName, ConfigurationValue, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDatetime
					from Configuration
					" + where_clause, inputs);
        }

        public DataTable select()
        {
            return select("");
        }

        public DataTable selectPK(long ID)
        {
            return select(@"where ID=@ID"
                , ID);
        }

        public TBL_Configuration select2(string where_clause, params object[] inputs)
        {
            DataTable dt = select(where_clause, inputs);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_Configuration.ReadRow(dt.Rows[0]);
        }

        public TBL_Configuration selectPK2(long ID)
        {
            DataTable dt = selectPK(ID);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_Configuration.ReadRow(dt.Rows[0]);
        }

        public DataTable select_join(long ID)
        {
            return select_join("where Configuration.ID=@ID", ID);
        }

        public DataTable select_join()
        {
            return select_join("");
        }

        public DataTable select_join(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select Configuration.ID, Configuration.ConfigurationName, Configuration.ConfigurationValue, Configuration.CreatedBy, Configuration.CreatedDatetime, Configuration.ModifiedBy, Configuration.ModifiedDatetime
					from Configuration
					" + where_clause, inputs);
        }

        public void insert
        (
            ref long? ID,
            string ConfigurationName,
            string ConfigurationValue,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDatetime
        )
        {

            m_db.Exec(@"
					insert into Configuration(
						ConfigurationName,
						ConfigurationValue,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDatetime
						)
					values(
						@ConfigurationName,
						@ConfigurationValue,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDatetime
						)
					", ConfigurationName, ConfigurationValue, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDatetime);

            ID = m_db.SelectInt("select IDENT_CURRENT('Configuration')");
        }

        public void insert
        (
            string ConfigurationName,
            string ConfigurationValue,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDatetime
        )
        {
            m_db.Exec(@"
					insert into Configuration(
						ConfigurationName,
						ConfigurationValue,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDatetime
						)
					values(
						@ConfigurationName,
						@ConfigurationValue,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDatetime
						)
					", ConfigurationName, ConfigurationValue, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDatetime);
        }

        public void update
        (
            long ID,
            string ConfigurationName,
            string ConfigurationValue,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDatetime
        )
        {
            int count = m_db.SelectCount(@"select * from Configuration where ID=@ID", ID);
            if (count == 0)
                throw new Exception("Configuration.update error. ID does not exists");

            m_db.Exec(@"
					update Configuration
					set
						ConfigurationName = @ConfigurationName,
						ConfigurationValue = @ConfigurationValue,
						CreatedBy = @CreatedBy,
						CreatedDatetime = @CreatedDatetime,
						ModifiedBy = @ModifiedBy,
						ModifiedDatetime = @ModifiedDatetime
					where ID=@ID
					",
                ConfigurationName,
                ConfigurationValue,
                CreatedBy,
                CreatedDatetime,
                ModifiedBy,
                ModifiedDatetime,
                ID
            );
        }

        public void delete(long ID)
        {
            int count = m_db.SelectCount(@"select * from Configuration where ID=@ID", ID);
            if (count == 0)
                throw new Exception("Configuration.delete error. ID does not exists");

            m_db.Exec(@"delete from Configuration where ID=@ID", ID);
        }

    }

    #endregion

    #region CostCentresInSite
    //**********************************************************
    //  CostCentresInSite
    //**********************************************************
    CMD_CostCentresInSite m_CostCentresInSite = null;
    public CMD_CostCentresInSite CostCentresInSite
    {
        get
        {
            if (m_CostCentresInSite == null)
                m_CostCentresInSite = new CMD_CostCentresInSite(this);
            return m_CostCentresInSite;
        }
    }

    [Serializable]
    public class TBL_CostCentresInSite
    {
        public long ID { get; set; }
        public long SiteID { get; set; }
        public string CostCentreIDName { get; set; }
        public string CostCentreName { get; set; }
        public int CostCentreStatus { get; set; }
        public long CreatedBy { get; set; }
        public DateTime CreatedDatetime { get; set; }
        public long ModifiedBy { get; set; }
        public DateTime ModifiedDateTime { get; set; }

        public TBL_CostCentresInSite()
        {
            this.ID = 0;
            this.SiteID = 0;
            this.CostCentreIDName = "";
            this.CostCentreName = "";
            this.CostCentreStatus = 0;
            this.CreatedBy = 0;
            this.CreatedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
            this.ModifiedBy = 0;
            this.ModifiedDateTime = Convert.ToDateTime("1900-01-01 00:00:00");
        }

        public TBL_CostCentresInSite(long ID, long SiteID, string CostCentreIDName, string CostCentreName, int CostCentreStatus, long CreatedBy, DateTime CreatedDatetime, long ModifiedBy, DateTime ModifiedDateTime)
        {
            this.ID = ID;
            this.SiteID = SiteID;
            this.CostCentreIDName = CostCentreIDName;
            this.CostCentreName = CostCentreName;
            this.CostCentreStatus = CostCentreStatus;
            this.CreatedBy = CreatedBy;
            this.CreatedDatetime = CreatedDatetime;
            this.ModifiedBy = ModifiedBy;
            this.ModifiedDateTime = ModifiedDateTime;
        }

        public void CopyTo(ref TBL_CostCentresInSite to)
        {
            to.ID = this.ID;
            to.SiteID = this.SiteID;
            to.CostCentreIDName = this.CostCentreIDName;
            to.CostCentreName = this.CostCentreName;
            to.CostCentreStatus = this.CostCentreStatus;
            to.CreatedBy = this.CreatedBy;
            to.CreatedDatetime = this.CreatedDatetime;
            to.ModifiedBy = this.ModifiedBy;
            to.ModifiedDateTime = this.ModifiedDateTime;
        }

        public bool IsSame(TBL_CostCentresInSite x)
        {
            return (
                this.ID == x.ID &&
                this.SiteID == x.SiteID &&
                this.CostCentreIDName == x.CostCentreIDName &&
                this.CostCentreName == x.CostCentreName &&
                this.CostCentreStatus == x.CostCentreStatus &&
                this.CreatedBy == x.CreatedBy &&
                this.CreatedDatetime == x.CreatedDatetime &&
                this.ModifiedBy == x.ModifiedBy &&
                this.ModifiedDateTime == x.ModifiedDateTime
            );
        }

        public static TBL_CostCentresInSite ReadRow(DataRow row)
        {
            TBL_CostCentresInSite record = new TBL_CostCentresInSite();
            record.ID = get_long_value(row["ID"]);
            record.SiteID = get_long_value(row["SiteID"]);
            record.CostCentreIDName = get_string_value(row["CostCentreIDName"]);
            record.CostCentreName = get_string_value(row["CostCentreName"]);
            record.CostCentreStatus = get_int_value(row["CostCentreStatus"]);
            record.CreatedBy = get_long_value(row["CreatedBy"]);
            record.CreatedDatetime = get_DateTime_value(row["CreatedDatetime"]);
            record.ModifiedBy = get_long_value(row["ModifiedBy"]);
            record.ModifiedDateTime = get_DateTime_value(row["ModifiedDateTime"]);
            return record;
        }

        public static List<TBL_CostCentresInSite> ReadTable(DataTable dt)
        {
            List<TBL_CostCentresInSite> records = new List<TBL_CostCentresInSite>();
            foreach (DataRow row in dt.Rows)
                records.Add(ReadRow(row));
            return records;
        }
    }

    public class CMD_CostCentresInSite
    {
        private MyLib.DAL_MSSQL m_db = null;

        public CMD_CostCentresInSite(MyLib.DAL_MSSQL db)
        {
            m_db = db;
        }

        public DataTable select(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select ID, SiteID, CostCentreIDName, CostCentreName, CostCentreStatus, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime
					from CostCentresInSite
					" + where_clause, inputs);
        }

        public DataTable select()
        {
            return select("");
        }

        public DataTable selectPK(long ID)
        {
            return select(@"where ID=@ID"
                , ID);
        }

        public TBL_CostCentresInSite select2(string where_clause, params object[] inputs)
        {
            DataTable dt = select(where_clause, inputs);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_CostCentresInSite.ReadRow(dt.Rows[0]);
        }

        public TBL_CostCentresInSite selectPK2(long ID)
        {
            DataTable dt = selectPK(ID);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_CostCentresInSite.ReadRow(dt.Rows[0]);
        }

        public DataTable select_join(long ID)
        {
            return select_join("where CostCentresInSite.ID=@ID", ID);
        }

        public DataTable select_join()
        {
            return select_join("");
        }

        public DataTable select_join(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select CostCentresInSite.ID, CostCentresInSite.SiteID, CostCentresInSite.CostCentreIDName, CostCentresInSite.CostCentreName, CostCentresInSite.CostCentreStatus, CostCentresInSite.CreatedBy, CostCentresInSite.CreatedDatetime, CostCentresInSite.ModifiedBy, CostCentresInSite.ModifiedDateTime
					from CostCentresInSite
					" + where_clause, inputs);
        }

        public void insert
        (
            ref long? ID,
            long? SiteID,
            string CostCentreIDName,
            string CostCentreName,
            int? CostCentreStatus,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDateTime
        )
        {

            m_db.Exec(@"
					insert into CostCentresInSite(
						SiteID,
						CostCentreIDName,
						CostCentreName,
						CostCentreStatus,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDateTime
						)
					values(
						@SiteID,
						@CostCentreIDName,
						@CostCentreName,
						@CostCentreStatus,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDateTime
						)
					", SiteID, CostCentreIDName, CostCentreName, CostCentreStatus, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime);

            ID = m_db.SelectInt("select IDENT_CURRENT('CostCentresInSite')");
        }

        public void insert
        (
            long? SiteID,
            string CostCentreIDName,
            string CostCentreName,
            int? CostCentreStatus,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDateTime
        )
        {
            m_db.Exec(@"
					insert into CostCentresInSite(
						SiteID,
						CostCentreIDName,
						CostCentreName,
						CostCentreStatus,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDateTime
						)
					values(
						@SiteID,
						@CostCentreIDName,
						@CostCentreName,
						@CostCentreStatus,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDateTime
						)
					", SiteID, CostCentreIDName, CostCentreName, CostCentreStatus, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime);
        }

        public void update
        (
            long ID,
            long? SiteID,
            string CostCentreIDName,
            string CostCentreName,
            int? CostCentreStatus,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDateTime
        )
        {
            int count = m_db.SelectCount(@"select * from CostCentresInSite where ID=@ID", ID);
            if (count == 0)
                throw new Exception("CostCentresInSite.update error. ID does not exists");

            m_db.Exec(@"
					update CostCentresInSite
					set
						SiteID = @SiteID,
						CostCentreIDName = @CostCentreIDName,
						CostCentreName = @CostCentreName,
						CostCentreStatus = @CostCentreStatus,
						CreatedBy = @CreatedBy,
						CreatedDatetime = @CreatedDatetime,
						ModifiedBy = @ModifiedBy,
						ModifiedDateTime = @ModifiedDateTime
					where ID=@ID
					",
                SiteID,
                CostCentreIDName,
                CostCentreName,
                CostCentreStatus,
                CreatedBy,
                CreatedDatetime,
                ModifiedBy,
                ModifiedDateTime,
                ID
            );
        }

        public void delete(long ID)
        {
            int count = m_db.SelectCount(@"select * from CostCentresInSite where ID=@ID", ID);
            if (count == 0)
                throw new Exception("CostCentresInSite.delete error. ID does not exists");

            m_db.Exec(@"delete from CostCentresInSite where ID=@ID", ID);
        }

    }

    #endregion

    #region DetailsInChangeRequest
    //**********************************************************
    //  DetailsInChangeRequest
    //**********************************************************
    CMD_DetailsInChangeRequest m_DetailsInChangeRequest = null;
    public CMD_DetailsInChangeRequest DetailsInChangeRequest
    {
        get
        {
            if (m_DetailsInChangeRequest == null)
                m_DetailsInChangeRequest = new CMD_DetailsInChangeRequest(this);
            return m_DetailsInChangeRequest;
        }
    }

    [Serializable]
    public class TBL_DetailsInChangeRequest
    {
        public long ID { get; set; }
        public long ChangeRequestID { get; set; }
        public long New_CostCentreID { get; set; }
        public DateTime New_EffectiveDate { get; set; }
        public DateTime New_TerminatedDate { get; set; }
        public string New_Email { get; set; }
        public string New_Username { get; set; }
        public string New_AssetID { get; set; }
        public string New_ServiceType { get; set; }
        public string New_Hostname { get; set; }
        public string New_OS { get; set; }
        public int New_Status { get; set; }
        public long Old_CostCentreID { get; set; }
        public DateTime Old_EffectiveDate { get; set; }
        public DateTime Old_TerminatedDate { get; set; }
        public long Old_TerminatedBy { get; set; }
        public long Old_CreatedBy { get; set; }
        public DateTime Old_CreatedDatetime { get; set; }
        public long Old_ModifiedBy { get; set; }
        public DateTime Old_ModifiedDateTime { get; set; }
        public string Old_Email { get; set; }
        public string Old_Username { get; set; }
        public string Old_AssetID { get; set; }
        public string Old_ServiceType { get; set; }
        public string Old_Hostname { get; set; }
        public string Old_OS { get; set; }
        public int Old_Status { get; set; }

        public TBL_DetailsInChangeRequest()
        {
            this.ID = 0;
            this.ChangeRequestID = 0;
            this.New_CostCentreID = 0;
            this.New_EffectiveDate = Convert.ToDateTime("1900-01-01 00:00:00");
            this.New_TerminatedDate = Convert.ToDateTime("1900-01-01 00:00:00");
            this.New_Email = "";
            this.New_Username = "";
            this.New_AssetID = "";
            this.New_ServiceType = "";
            this.New_Hostname = "";
            this.New_OS = "";
            this.New_Status = 0;
            this.Old_CostCentreID = 0;
            this.Old_EffectiveDate = Convert.ToDateTime("1900-01-01 00:00:00");
            this.Old_TerminatedDate = Convert.ToDateTime("1900-01-01 00:00:00");
            this.Old_TerminatedBy = 0;
            this.Old_CreatedBy = 0;
            this.Old_CreatedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
            this.Old_ModifiedBy = 0;
            this.Old_ModifiedDateTime = Convert.ToDateTime("1900-01-01 00:00:00");
            this.Old_Email = "";
            this.Old_Username = "";
            this.Old_AssetID = "";
            this.Old_ServiceType = "";
            this.Old_Hostname = "";
            this.Old_OS = "";
            this.Old_Status = 0;
        }

        public TBL_DetailsInChangeRequest(long ID, long ChangeRequestID, long New_CostCentreID, DateTime New_EffectiveDate, DateTime New_TerminatedDate, string New_Email, string New_Username, string New_AssetID, string New_ServiceType, string New_Hostname, string New_OS, int New_Status, long Old_CostCentreID, DateTime Old_EffectiveDate, DateTime Old_TerminatedDate, long Old_TerminatedBy, long Old_CreatedBy, DateTime Old_CreatedDatetime, long Old_ModifiedBy, DateTime Old_ModifiedDateTime, string Old_Email, string Old_Username, string Old_AssetID, string Old_ServiceType, string Old_Hostname, string Old_OS, int Old_Status)
        {
            this.ID = ID;
            this.ChangeRequestID = ChangeRequestID;
            this.New_CostCentreID = New_CostCentreID;
            this.New_EffectiveDate = New_EffectiveDate;
            this.New_TerminatedDate = New_TerminatedDate;
            this.New_Email = New_Email;
            this.New_Username = New_Username;
            this.New_AssetID = New_AssetID;
            this.New_ServiceType = New_ServiceType;
            this.New_Hostname = New_Hostname;
            this.New_OS = New_OS;
            this.New_Status = New_Status;
            this.Old_CostCentreID = Old_CostCentreID;
            this.Old_EffectiveDate = Old_EffectiveDate;
            this.Old_TerminatedDate = Old_TerminatedDate;
            this.Old_TerminatedBy = Old_TerminatedBy;
            this.Old_CreatedBy = Old_CreatedBy;
            this.Old_CreatedDatetime = Old_CreatedDatetime;
            this.Old_ModifiedBy = Old_ModifiedBy;
            this.Old_ModifiedDateTime = Old_ModifiedDateTime;
            this.Old_Email = Old_Email;
            this.Old_Username = Old_Username;
            this.Old_AssetID = Old_AssetID;
            this.Old_ServiceType = Old_ServiceType;
            this.Old_Hostname = Old_Hostname;
            this.Old_OS = Old_OS;
            this.Old_Status = Old_Status;
        }

        public void CopyTo(ref TBL_DetailsInChangeRequest to)
        {
            to.ID = this.ID;
            to.ChangeRequestID = this.ChangeRequestID;
            to.New_CostCentreID = this.New_CostCentreID;
            to.New_EffectiveDate = this.New_EffectiveDate;
            to.New_TerminatedDate = this.New_TerminatedDate;
            to.New_Email = this.New_Email;
            to.New_Username = this.New_Username;
            to.New_AssetID = this.New_AssetID;
            to.New_ServiceType = this.New_ServiceType;
            to.New_Hostname = this.New_Hostname;
            to.New_OS = this.New_OS;
            to.New_Status = this.New_Status;
            to.Old_CostCentreID = this.Old_CostCentreID;
            to.Old_EffectiveDate = this.Old_EffectiveDate;
            to.Old_TerminatedDate = this.Old_TerminatedDate;
            to.Old_TerminatedBy = this.Old_TerminatedBy;
            to.Old_CreatedBy = this.Old_CreatedBy;
            to.Old_CreatedDatetime = this.Old_CreatedDatetime;
            to.Old_ModifiedBy = this.Old_ModifiedBy;
            to.Old_ModifiedDateTime = this.Old_ModifiedDateTime;
            to.Old_Email = this.Old_Email;
            to.Old_Username = this.Old_Username;
            to.Old_AssetID = this.Old_AssetID;
            to.Old_ServiceType = this.Old_ServiceType;
            to.Old_Hostname = this.Old_Hostname;
            to.Old_OS = this.Old_OS;
            to.Old_Status = this.Old_Status;
        }

        public bool IsSame(TBL_DetailsInChangeRequest x)
        {
            return (
                this.ID == x.ID &&
                this.ChangeRequestID == x.ChangeRequestID &&
                this.New_CostCentreID == x.New_CostCentreID &&
                this.New_EffectiveDate == x.New_EffectiveDate &&
                this.New_TerminatedDate == x.New_TerminatedDate &&
                this.New_Email == x.New_Email &&
                this.New_Username == x.New_Username &&
                this.New_AssetID == x.New_AssetID &&
                this.New_ServiceType == x.New_ServiceType &&
                this.New_Hostname == x.New_Hostname &&
                this.New_OS == x.New_OS &&
                this.New_Status == x.New_Status &&
                this.Old_CostCentreID == x.Old_CostCentreID &&
                this.Old_EffectiveDate == x.Old_EffectiveDate &&
                this.Old_TerminatedDate == x.Old_TerminatedDate &&
                this.Old_TerminatedBy == x.Old_TerminatedBy &&
                this.Old_CreatedBy == x.Old_CreatedBy &&
                this.Old_CreatedDatetime == x.Old_CreatedDatetime &&
                this.Old_ModifiedBy == x.Old_ModifiedBy &&
                this.Old_ModifiedDateTime == x.Old_ModifiedDateTime &&
                this.Old_Email == x.Old_Email &&
                this.Old_Username == x.Old_Username &&
                this.Old_AssetID == x.Old_AssetID &&
                this.Old_ServiceType == x.Old_ServiceType &&
                this.Old_Hostname == x.Old_Hostname &&
                this.Old_OS == x.Old_OS &&
                this.Old_Status == x.Old_Status
            );
        }

        public static TBL_DetailsInChangeRequest ReadRow(DataRow row)
        {
            TBL_DetailsInChangeRequest record = new TBL_DetailsInChangeRequest();
            record.ID = get_long_value(row["ID"]);
            record.ChangeRequestID = get_long_value(row["ChangeRequestID"]);
            record.New_CostCentreID = get_long_value(row["New_CostCentreID"]);
            record.New_EffectiveDate = get_DateTime_value(row["New_EffectiveDate"]);
            record.New_TerminatedDate = get_DateTime_value(row["New_TerminatedDate"]);
            record.New_Email = get_string_value(row["New_Email"]);
            record.New_Username = get_string_value(row["New_Username"]);
            record.New_AssetID = get_string_value(row["New_AssetID"]);
            record.New_ServiceType = get_string_value(row["New_ServiceType"]);
            record.New_Hostname = get_string_value(row["New_Hostname"]);
            record.New_OS = get_string_value(row["New_OS"]);
            record.New_Status = get_int_value(row["New_Status"]);
            record.Old_CostCentreID = get_long_value(row["Old_CostCentreID"]);
            record.Old_EffectiveDate = get_DateTime_value(row["Old_EffectiveDate"]);
            record.Old_TerminatedDate = get_DateTime_value(row["Old_TerminatedDate"]);
            record.Old_TerminatedBy = get_long_value(row["Old_TerminatedBy"]);
            record.Old_CreatedBy = get_long_value(row["Old_CreatedBy"]);
            record.Old_CreatedDatetime = get_DateTime_value(row["Old_CreatedDatetime"]);
            record.Old_ModifiedBy = get_long_value(row["Old_ModifiedBy"]);
            record.Old_ModifiedDateTime = get_DateTime_value(row["Old_ModifiedDateTime"]);
            record.Old_Email = get_string_value(row["Old_Email"]);
            record.Old_Username = get_string_value(row["Old_Username"]);
            record.Old_AssetID = get_string_value(row["Old_AssetID"]);
            record.Old_ServiceType = get_string_value(row["Old_ServiceType"]);
            record.Old_Hostname = get_string_value(row["Old_Hostname"]);
            record.Old_OS = get_string_value(row["Old_OS"]);
            record.Old_Status = get_int_value(row["Old_Status"]);
            return record;
        }

        public static List<TBL_DetailsInChangeRequest> ReadTable(DataTable dt)
        {
            List<TBL_DetailsInChangeRequest> records = new List<TBL_DetailsInChangeRequest>();
            foreach (DataRow row in dt.Rows)
                records.Add(ReadRow(row));
            return records;
        }
    }

    public class CMD_DetailsInChangeRequest
    {
        private MyLib.DAL_MSSQL m_db = null;

        public CMD_DetailsInChangeRequest(MyLib.DAL_MSSQL db)
        {
            m_db = db;
        }

        public DataTable select(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select ID, ChangeRequestID, New_CostCentreID, New_EffectiveDate, New_TerminatedDate, New_Email, New_Username, New_AssetID, New_ServiceType, New_Hostname, New_OS, New_Status, Old_CostCentreID, Old_EffectiveDate, Old_TerminatedDate, Old_TerminatedBy, Old_CreatedBy, Old_CreatedDatetime, Old_ModifiedBy, Old_ModifiedDateTime, Old_Email, Old_Username, Old_AssetID, Old_ServiceType, Old_Hostname, Old_OS, Old_Status
					from DetailsInChangeRequest
					" + where_clause, inputs);
        }

        public DataTable select()
        {
            return select("");
        }

        public DataTable selectPK(long ID)
        {
            return select(@"where ID=@ID"
                , ID);
        }

        public TBL_DetailsInChangeRequest select2(string where_clause, params object[] inputs)
        {
            DataTable dt = select(where_clause, inputs);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_DetailsInChangeRequest.ReadRow(dt.Rows[0]);
        }

        public TBL_DetailsInChangeRequest selectPK2(long ID)
        {
            DataTable dt = selectPK(ID);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_DetailsInChangeRequest.ReadRow(dt.Rows[0]);
        }

        public DataTable select_join(long ID)
        {
            return select_join("where DetailsInChangeRequest.ID=@ID", ID);
        }

        public DataTable select_join()
        {
            return select_join("");
        }

        public DataTable select_join(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select DetailsInChangeRequest.ID, DetailsInChangeRequest.ChangeRequestID, DetailsInChangeRequest.New_CostCentreID, DetailsInChangeRequest.New_EffectiveDate, DetailsInChangeRequest.New_TerminatedDate, DetailsInChangeRequest.New_Email, DetailsInChangeRequest.New_Username, DetailsInChangeRequest.New_AssetID, DetailsInChangeRequest.New_ServiceType, DetailsInChangeRequest.New_Hostname, DetailsInChangeRequest.New_OS, DetailsInChangeRequest.New_Status, DetailsInChangeRequest.Old_CostCentreID, DetailsInChangeRequest.Old_EffectiveDate, DetailsInChangeRequest.Old_TerminatedDate, DetailsInChangeRequest.Old_TerminatedBy, DetailsInChangeRequest.Old_CreatedBy, DetailsInChangeRequest.Old_CreatedDatetime, DetailsInChangeRequest.Old_ModifiedBy, DetailsInChangeRequest.Old_ModifiedDateTime, DetailsInChangeRequest.Old_Email, DetailsInChangeRequest.Old_Username, DetailsInChangeRequest.Old_AssetID, DetailsInChangeRequest.Old_ServiceType, DetailsInChangeRequest.Old_Hostname, DetailsInChangeRequest.Old_OS, DetailsInChangeRequest.Old_Status
					from DetailsInChangeRequest
					" + where_clause, inputs);
        }

        public void insert
        (
            ref long? ID,
            long? ChangeRequestID,
            long? New_CostCentreID,
            DateTime? New_EffectiveDate,
            DateTime? New_TerminatedDate,
            string New_Email,
            string New_Username,
            string New_AssetID,
            string New_ServiceType,
            string New_Hostname,
            string New_OS,
            int? New_Status,
            long? Old_CostCentreID,
            DateTime? Old_EffectiveDate,
            DateTime? Old_TerminatedDate,
            long? Old_TerminatedBy,
            long? Old_CreatedBy,
            DateTime? Old_CreatedDatetime,
            long? Old_ModifiedBy,
            DateTime? Old_ModifiedDateTime,
            string Old_Email,
            string Old_Username,
            string Old_AssetID,
            string Old_ServiceType,
            string Old_Hostname,
            string Old_OS,
            int? Old_Status
        )
        {

            m_db.Exec(@"
					insert into DetailsInChangeRequest(
						ChangeRequestID,
						New_CostCentreID,
						New_EffectiveDate,
						New_TerminatedDate,
						New_Email,
						New_Username,
						New_AssetID,
						New_ServiceType,
						New_Hostname,
						New_OS,
						New_Status,
						Old_CostCentreID,
						Old_EffectiveDate,
						Old_TerminatedDate,
						Old_TerminatedBy,
						Old_CreatedBy,
						Old_CreatedDatetime,
						Old_ModifiedBy,
						Old_ModifiedDateTime,
						Old_Email,
						Old_Username,
						Old_AssetID,
						Old_ServiceType,
						Old_Hostname,
						Old_OS,
						Old_Status
						)
					values(
						@ChangeRequestID,
						@New_CostCentreID,
						@New_EffectiveDate,
						@New_TerminatedDate,
						@New_Email,
						@New_Username,
						@New_AssetID,
						@New_ServiceType,
						@New_Hostname,
						@New_OS,
						@New_Status,
						@Old_CostCentreID,
						@Old_EffectiveDate,
						@Old_TerminatedDate,
						@Old_TerminatedBy,
						@Old_CreatedBy,
						@Old_CreatedDatetime,
						@Old_ModifiedBy,
						@Old_ModifiedDateTime,
						@Old_Email,
						@Old_Username,
						@Old_AssetID,
						@Old_ServiceType,
						@Old_Hostname,
						@Old_OS,
						@Old_Status
						)
					", ChangeRequestID, New_CostCentreID, New_EffectiveDate, New_TerminatedDate, New_Email, New_Username, New_AssetID, New_ServiceType, New_Hostname, New_OS, New_Status, Old_CostCentreID, Old_EffectiveDate, Old_TerminatedDate, Old_TerminatedBy, Old_CreatedBy, Old_CreatedDatetime, Old_ModifiedBy, Old_ModifiedDateTime, Old_Email, Old_Username, Old_AssetID, Old_ServiceType, Old_Hostname, Old_OS, Old_Status);

            ID = m_db.SelectInt("select IDENT_CURRENT('DetailsInChangeRequest')");
        }

        public void insert
        (
            long? ChangeRequestID,
            long? New_CostCentreID,
            DateTime? New_EffectiveDate,
            DateTime? New_TerminatedDate,
            string New_Email,
            string New_Username,
            string New_AssetID,
            string New_ServiceType,
            string New_Hostname,
            string New_OS,
            int? New_Status,
            long? Old_CostCentreID,
            DateTime? Old_EffectiveDate,
            DateTime? Old_TerminatedDate,
            long? Old_TerminatedBy,
            long? Old_CreatedBy,
            DateTime? Old_CreatedDatetime,
            long? Old_ModifiedBy,
            DateTime? Old_ModifiedDateTime,
            string Old_Email,
            string Old_Username,
            string Old_AssetID,
            string Old_ServiceType,
            string Old_Hostname,
            string Old_OS,
            int? Old_Status
        )
        {
            m_db.Exec(@"
					insert into DetailsInChangeRequest(
						ChangeRequestID,
						New_CostCentreID,
						New_EffectiveDate,
						New_TerminatedDate,
						New_Email,
						New_Username,
						New_AssetID,
						New_ServiceType,
						New_Hostname,
						New_OS,
						New_Status,
						Old_CostCentreID,
						Old_EffectiveDate,
						Old_TerminatedDate,
						Old_TerminatedBy,
						Old_CreatedBy,
						Old_CreatedDatetime,
						Old_ModifiedBy,
						Old_ModifiedDateTime,
						Old_Email,
						Old_Username,
						Old_AssetID,
						Old_ServiceType,
						Old_Hostname,
						Old_OS,
						Old_Status
						)
					values(
						@ChangeRequestID,
						@New_CostCentreID,
						@New_EffectiveDate,
						@New_TerminatedDate,
						@New_Email,
						@New_Username,
						@New_AssetID,
						@New_ServiceType,
						@New_Hostname,
						@New_OS,
						@New_Status,
						@Old_CostCentreID,
						@Old_EffectiveDate,
						@Old_TerminatedDate,
						@Old_TerminatedBy,
						@Old_CreatedBy,
						@Old_CreatedDatetime,
						@Old_ModifiedBy,
						@Old_ModifiedDateTime,
						@Old_Email,
						@Old_Username,
						@Old_AssetID,
						@Old_ServiceType,
						@Old_Hostname,
						@Old_OS,
						@Old_Status
						)
					", ChangeRequestID, New_CostCentreID, New_EffectiveDate, New_TerminatedDate, New_Email, New_Username, New_AssetID, New_ServiceType, New_Hostname, New_OS, New_Status, Old_CostCentreID, Old_EffectiveDate, Old_TerminatedDate, Old_TerminatedBy, Old_CreatedBy, Old_CreatedDatetime, Old_ModifiedBy, Old_ModifiedDateTime, Old_Email, Old_Username, Old_AssetID, Old_ServiceType, Old_Hostname, Old_OS, Old_Status);
        }

        public void update
        (
            long ID,
            long? ChangeRequestID,
            long? New_CostCentreID,
            DateTime? New_EffectiveDate,
            DateTime? New_TerminatedDate,
            string New_Email,
            string New_Username,
            string New_AssetID,
            string New_ServiceType,
            string New_Hostname,
            string New_OS,
            int? New_Status,
            long? Old_CostCentreID,
            DateTime? Old_EffectiveDate,
            DateTime? Old_TerminatedDate,
            long? Old_TerminatedBy,
            long? Old_CreatedBy,
            DateTime? Old_CreatedDatetime,
            long? Old_ModifiedBy,
            DateTime? Old_ModifiedDateTime,
            string Old_Email,
            string Old_Username,
            string Old_AssetID,
            string Old_ServiceType,
            string Old_Hostname,
            string Old_OS,
            int? Old_Status
        )
        {
            int count = m_db.SelectCount(@"select * from DetailsInChangeRequest where ID=@ID", ID);
            if (count == 0)
                throw new Exception("DetailsInChangeRequest.update error. ID does not exists");

            m_db.Exec(@"
					update DetailsInChangeRequest
					set
						ChangeRequestID = @ChangeRequestID,
						New_CostCentreID = @New_CostCentreID,
						New_EffectiveDate = @New_EffectiveDate,
						New_TerminatedDate = @New_TerminatedDate,
						New_Email = @New_Email,
						New_Username = @New_Username,
						New_AssetID = @New_AssetID,
						New_ServiceType = @New_ServiceType,
						New_Hostname = @New_Hostname,
						New_OS = @New_OS,
						New_Status = @New_Status,
						Old_CostCentreID = @Old_CostCentreID,
						Old_EffectiveDate = @Old_EffectiveDate,
						Old_TerminatedDate = @Old_TerminatedDate,
						Old_TerminatedBy = @Old_TerminatedBy,
						Old_CreatedBy = @Old_CreatedBy,
						Old_CreatedDatetime = @Old_CreatedDatetime,
						Old_ModifiedBy = @Old_ModifiedBy,
						Old_ModifiedDateTime = @Old_ModifiedDateTime,
						Old_Email = @Old_Email,
						Old_Username = @Old_Username,
						Old_AssetID = @Old_AssetID,
						Old_ServiceType = @Old_ServiceType,
						Old_Hostname = @Old_Hostname,
						Old_OS = @Old_OS,
						Old_Status = @Old_Status
					where ID=@ID
					",
                ChangeRequestID,
                New_CostCentreID,
                New_EffectiveDate,
                New_TerminatedDate,
                New_Email,
                New_Username,
                New_AssetID,
                New_ServiceType,
                New_Hostname,
                New_OS,
                New_Status,
                Old_CostCentreID,
                Old_EffectiveDate,
                Old_TerminatedDate,
                Old_TerminatedBy,
                Old_CreatedBy,
                Old_CreatedDatetime,
                Old_ModifiedBy,
                Old_ModifiedDateTime,
                Old_Email,
                Old_Username,
                Old_AssetID,
                Old_ServiceType,
                Old_Hostname,
                Old_OS,
                Old_Status,
                ID
            );
        }

        public void delete(long ID)
        {
            int count = m_db.SelectCount(@"select * from DetailsInChangeRequest where ID=@ID", ID);
            if (count == 0)
                throw new Exception("DetailsInChangeRequest.delete error. ID does not exists");

            m_db.Exec(@"delete from DetailsInChangeRequest where ID=@ID", ID);
        }

    }

    #endregion

    #region DomainsInSite
    //**********************************************************
    //  DomainsInSite
    //**********************************************************
    CMD_DomainsInSite m_DomainsInSite = null;
    public CMD_DomainsInSite DomainsInSite
    {
        get
        {
            if (m_DomainsInSite == null)
                m_DomainsInSite = new CMD_DomainsInSite(this);
            return m_DomainsInSite;
        }
    }

    [Serializable]
    public class TBL_DomainsInSite
    {
        public long ID { get; set; }
        public long SiteID { get; set; }
        public string DomainName { get; set; }
        public int DomainStatus { get; set; }

        public TBL_DomainsInSite()
        {
            this.ID = 0;
            this.SiteID = 0;
            this.DomainName = "";
            this.DomainStatus = 0;
        }

        public TBL_DomainsInSite(long ID, long SiteID, string DomainName, int DomainStatus)
        {
            this.ID = ID;
            this.SiteID = SiteID;
            this.DomainName = DomainName;
            this.DomainStatus = DomainStatus;
        }

        public void CopyTo(ref TBL_DomainsInSite to)
        {
            to.ID = this.ID;
            to.SiteID = this.SiteID;
            to.DomainName = this.DomainName;
            to.DomainStatus = this.DomainStatus;
        }

        public bool IsSame(TBL_DomainsInSite x)
        {
            return (
                this.ID == x.ID &&
                this.SiteID == x.SiteID &&
                this.DomainName == x.DomainName &&
                this.DomainStatus == x.DomainStatus
            );
        }

        public static TBL_DomainsInSite ReadRow(DataRow row)
        {
            TBL_DomainsInSite record = new TBL_DomainsInSite();
            record.ID = get_long_value(row["ID"]);
            record.SiteID = get_long_value(row["SiteID"]);
            record.DomainName = get_string_value(row["DomainName"]);
            record.DomainStatus = get_int_value(row["DomainStatus"]);
            return record;
        }

        public static List<TBL_DomainsInSite> ReadTable(DataTable dt)
        {
            List<TBL_DomainsInSite> records = new List<TBL_DomainsInSite>();
            foreach (DataRow row in dt.Rows)
                records.Add(ReadRow(row));
            return records;
        }
    }

    public class CMD_DomainsInSite
    {
        private MyLib.DAL_MSSQL m_db = null;

        public CMD_DomainsInSite(MyLib.DAL_MSSQL db)
        {
            m_db = db;
        }

        public DataTable select(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select ID, SiteID, DomainName, DomainStatus
					from DomainsInSite
					" + where_clause, inputs);
        }

        public DataTable select()
        {
            return select("");
        }

        public DataTable selectPK(long ID)
        {
            return select(@"where ID=@ID"
                , ID);
        }

        public TBL_DomainsInSite select2(string where_clause, params object[] inputs)
        {
            DataTable dt = select(where_clause, inputs);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_DomainsInSite.ReadRow(dt.Rows[0]);
        }

        public TBL_DomainsInSite selectPK2(long ID)
        {
            DataTable dt = selectPK(ID);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_DomainsInSite.ReadRow(dt.Rows[0]);
        }

        public DataTable select_join(long ID)
        {
            return select_join("where DomainsInSite.ID=@ID", ID);
        }

        public DataTable select_join()
        {
            return select_join("");
        }

        public DataTable select_join(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select DomainsInSite.ID, DomainsInSite.SiteID, DomainsInSite.DomainName, DomainsInSite.DomainStatus
					from DomainsInSite
					" + where_clause, inputs);
        }

        public void insert
        (
            ref long? ID,
            long? SiteID,
            string DomainName,
            int? DomainStatus
        )
        {

            m_db.Exec(@"
					insert into DomainsInSite(
						SiteID,
						DomainName,
						DomainStatus
						)
					values(
						@SiteID,
						@DomainName,
						@DomainStatus
						)
					", SiteID, DomainName, DomainStatus);

            ID = m_db.SelectInt("select IDENT_CURRENT('DomainsInSite')");
        }

        public void insert
        (
            long? SiteID,
            string DomainName,
            int? DomainStatus
        )
        {
            m_db.Exec(@"
					insert into DomainsInSite(
						SiteID,
						DomainName,
						DomainStatus
						)
					values(
						@SiteID,
						@DomainName,
						@DomainStatus
						)
					", SiteID, DomainName, DomainStatus);
        }

        public void update
        (
            long ID,
            long? SiteID,
            string DomainName,
            int? DomainStatus
        )
        {
            int count = m_db.SelectCount(@"select * from DomainsInSite where ID=@ID", ID);
            if (count == 0)
                throw new Exception("DomainsInSite.update error. ID does not exists");

            m_db.Exec(@"
					update DomainsInSite
					set
						SiteID = @SiteID,
						DomainName = @DomainName,
						DomainStatus = @DomainStatus
					where ID=@ID
					",
                SiteID,
                DomainName,
                DomainStatus,
                ID
            );
        }

        public void delete(long ID)
        {
            int count = m_db.SelectCount(@"select * from DomainsInSite where ID=@ID", ID);
            if (count == 0)
                throw new Exception("DomainsInSite.delete error. ID does not exists");

            m_db.Exec(@"delete from DomainsInSite where ID=@ID", ID);
        }

    }

    #endregion

    #region GeneralStatus
    //**********************************************************
    //  GeneralStatus
    //**********************************************************
    CMD_GeneralStatus m_GeneralStatus = null;
    public CMD_GeneralStatus GeneralStatus
    {
        get
        {
            if (m_GeneralStatus == null)
                m_GeneralStatus = new CMD_GeneralStatus(this);
            return m_GeneralStatus;
        }
    }

    [Serializable]
    public class TBL_GeneralStatus
    {
        public long ID { get; set; }
        public string Status0 { get; set; }

        public TBL_GeneralStatus()
        {
            this.ID = 0;
            this.Status0 = "";
        }

        public TBL_GeneralStatus(long ID, string Status0)
        {
            this.ID = ID;
            this.Status0 = Status0;
        }

        public void CopyTo(ref TBL_GeneralStatus to)
        {
            to.ID = this.ID;
            to.Status0 = this.Status0;
        }

        public bool IsSame(TBL_GeneralStatus x)
        {
            return (
                this.ID == x.ID &&
                this.Status0 == x.Status0
            );
        }

        public static TBL_GeneralStatus ReadRow(DataRow row)
        {
            TBL_GeneralStatus record = new TBL_GeneralStatus();
            record.ID = get_long_value(row["ID"]);
            record.Status0 = get_string_value(row["Status0"]);
            return record;
        }

        public static List<TBL_GeneralStatus> ReadTable(DataTable dt)
        {
            List<TBL_GeneralStatus> records = new List<TBL_GeneralStatus>();
            foreach (DataRow row in dt.Rows)
                records.Add(ReadRow(row));
            return records;
        }
    }

    public class CMD_GeneralStatus
    {
        private MyLib.DAL_MSSQL m_db = null;

        public CMD_GeneralStatus(MyLib.DAL_MSSQL db)
        {
            m_db = db;
        }

        public DataTable select(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select ID, Status0
					from GeneralStatus
					" + where_clause, inputs);
        }

        public DataTable select()
        {
            return select("");
        }

        public DataTable selectPK(long ID)
        {
            return select(@"where ID=@ID"
                , ID);
        }

        public TBL_GeneralStatus select2(string where_clause, params object[] inputs)
        {
            DataTable dt = select(where_clause, inputs);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_GeneralStatus.ReadRow(dt.Rows[0]);
        }

        public TBL_GeneralStatus selectPK2(long ID)
        {
            DataTable dt = selectPK(ID);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_GeneralStatus.ReadRow(dt.Rows[0]);
        }

        public DataTable select_join(long ID)
        {
            return select_join("where GeneralStatus.ID=@ID", ID);
        }

        public DataTable select_join()
        {
            return select_join("");
        }

        public DataTable select_join(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select GeneralStatus.ID, GeneralStatus.Status0
					from GeneralStatus
					" + where_clause, inputs);
        }

        public void insert
        (
            ref long? ID,
            string Status0
        )
        {

            m_db.Exec(@"
					insert into GeneralStatus(
						Status0
						)
					values(
						@Status0
						)
					", Status0);

            ID = m_db.SelectInt("select IDENT_CURRENT('GeneralStatus')");
        }

        public void insert
        (
            string Status0
        )
        {
            m_db.Exec(@"
					insert into GeneralStatus(
						Status0
						)
					values(
						@Status0
						)
					", Status0);
        }

        public void update
        (
            long ID,
            string Status0
        )
        {
            int count = m_db.SelectCount(@"select * from GeneralStatus where ID=@ID", ID);
            if (count == 0)
                throw new Exception("GeneralStatus.update error. ID does not exists");

            m_db.Exec(@"
					update GeneralStatus
					set
						Status0 = @Status0
					where ID=@ID
					",
                Status0,
                ID
            );
        }

        public void delete(long ID)
        {
            int count = m_db.SelectCount(@"select * from GeneralStatus where ID=@ID", ID);
            if (count == 0)
                throw new Exception("GeneralStatus.delete error. ID does not exists");

            m_db.Exec(@"delete from GeneralStatus where ID=@ID", ID);
        }

    }

    #endregion

    #region GroupMember
    //**********************************************************
    //  GroupMember
    //**********************************************************
    CMD_GroupMember m_GroupMember = null;
    public CMD_GroupMember GroupMember
    {
        get
        {
            if (m_GroupMember == null)
                m_GroupMember = new CMD_GroupMember(this);
            return m_GroupMember;
        }
    }

    [Serializable]
    public class TBL_GroupMember
    {
        public long GroupID { get; set; }
        public string GroupName { get; set; }
        public long CreatedBy { get; set; }
        public DateTime CreatedDatetime { get; set; }
        public long ModifiedBy { get; set; }
        public DateTime ModifiedDateTime { get; set; }
        public int GroupStatus { get; set; }

        public TBL_GroupMember()
        {
            this.GroupID = 0;
            this.GroupName = "";
            this.CreatedBy = 0;
            this.CreatedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
            this.ModifiedBy = 0;
            this.ModifiedDateTime = Convert.ToDateTime("1900-01-01 00:00:00");
            this.GroupStatus = 0;
        }

        public TBL_GroupMember(long GroupID, string GroupName, long CreatedBy, DateTime CreatedDatetime, long ModifiedBy, DateTime ModifiedDateTime, int GroupStatus)
        {
            this.GroupID = GroupID;
            this.GroupName = GroupName;
            this.CreatedBy = CreatedBy;
            this.CreatedDatetime = CreatedDatetime;
            this.ModifiedBy = ModifiedBy;
            this.ModifiedDateTime = ModifiedDateTime;
            this.GroupStatus = GroupStatus;
        }

        public void CopyTo(ref TBL_GroupMember to)
        {
            to.GroupID = this.GroupID;
            to.GroupName = this.GroupName;
            to.CreatedBy = this.CreatedBy;
            to.CreatedDatetime = this.CreatedDatetime;
            to.ModifiedBy = this.ModifiedBy;
            to.ModifiedDateTime = this.ModifiedDateTime;
            to.GroupStatus = this.GroupStatus;
        }

        public bool IsSame(TBL_GroupMember x)
        {
            return (
                this.GroupID == x.GroupID &&
                this.GroupName == x.GroupName &&
                this.CreatedBy == x.CreatedBy &&
                this.CreatedDatetime == x.CreatedDatetime &&
                this.ModifiedBy == x.ModifiedBy &&
                this.ModifiedDateTime == x.ModifiedDateTime &&
                this.GroupStatus == x.GroupStatus
            );
        }

        public static TBL_GroupMember ReadRow(DataRow row)
        {
            TBL_GroupMember record = new TBL_GroupMember();
            record.GroupID = get_long_value(row["GroupID"]);
            record.GroupName = get_string_value(row["GroupName"]);
            record.CreatedBy = get_long_value(row["CreatedBy"]);
            record.CreatedDatetime = get_DateTime_value(row["CreatedDatetime"]);
            record.ModifiedBy = get_long_value(row["ModifiedBy"]);
            record.ModifiedDateTime = get_DateTime_value(row["ModifiedDateTime"]);
            record.GroupStatus = get_int_value(row["GroupStatus"]);
            return record;
        }

        public static List<TBL_GroupMember> ReadTable(DataTable dt)
        {
            List<TBL_GroupMember> records = new List<TBL_GroupMember>();
            foreach (DataRow row in dt.Rows)
                records.Add(ReadRow(row));
            return records;
        }
    }

    public class CMD_GroupMember
    {
        private MyLib.DAL_MSSQL m_db = null;

        public CMD_GroupMember(MyLib.DAL_MSSQL db)
        {
            m_db = db;
        }

        public DataTable select(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select GroupID, GroupName, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime, GroupStatus
					from GroupMember
					" + where_clause, inputs);
        }

        public DataTable select()
        {
            return select("");
        }

        public DataTable selectPK(long GroupID)
        {
            return select(@"where GroupID=@GroupID"
                , GroupID);
        }

        public TBL_GroupMember select2(string where_clause, params object[] inputs)
        {
            DataTable dt = select(where_clause, inputs);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_GroupMember.ReadRow(dt.Rows[0]);
        }

        public TBL_GroupMember selectPK2(long GroupID)
        {
            DataTable dt = selectPK(GroupID);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_GroupMember.ReadRow(dt.Rows[0]);
        }

        public DataTable select_join(long GroupID)
        {
            return select_join("where GroupMember.GroupID=@GroupID", GroupID);
        }

        public DataTable select_join()
        {
            return select_join("");
        }

        public DataTable select_join(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select GroupMember.GroupID, GroupMember.GroupName, GroupMember.CreatedBy, GroupMember.CreatedDatetime, GroupMember.ModifiedBy, GroupMember.ModifiedDateTime, GroupMember.GroupStatus
					from GroupMember
					" + where_clause, inputs);
        }

        public void insert
        (
            ref long? GroupID,
            string GroupName,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDateTime,
            int? GroupStatus
        )
        {
            GroupID = m_db.SelectInt("select isnull(MAX(GroupID), 0) + 1 from GroupMember");

            m_db.Exec(@"
					insert into GroupMember(
						GroupID,
						GroupName,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDateTime,
						GroupStatus
						)
					values(
						@GroupID,
						@GroupName,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDateTime,
						@GroupStatus
						)
					", GroupID, GroupName, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime, GroupStatus);

        }

        public void insert
        (
            long? GroupID,
            string GroupName,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDateTime,
            int? GroupStatus
        )
        {
            int count = m_db.SelectCount(@"select * from GroupMember where GroupID=@GroupID", GroupID);
            if (count > 0)
                throw new Exception("GroupMember.insert error. ID duplicate");

            m_db.Exec(@"
					insert into GroupMember(
						GroupID,
						GroupName,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDateTime,
						GroupStatus
						)
					values(
						@GroupID,
						@GroupName,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDateTime,
						@GroupStatus
						)
					", GroupID, GroupName, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime, GroupStatus);
        }

        public void update
        (
            long _old_GroupID,
            long _new_GroupID,
            string GroupName,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDateTime,
            int? GroupStatus
        )
        {
            int count = m_db.SelectCount(@"select * from GroupMember where GroupID=@_old_GroupID", _old_GroupID);
            if (count == 0)
                throw new Exception("GroupMember.update error. ID does not exists");

            m_db.Exec(@"
					update GroupMember
					set
						GroupID = @_new_GroupID,
						GroupName = @GroupName,
						CreatedBy = @CreatedBy,
						CreatedDatetime = @CreatedDatetime,
						ModifiedBy = @ModifiedBy,
						ModifiedDateTime = @ModifiedDateTime,
						GroupStatus = @GroupStatus
					where GroupID=@_old_GroupID
					",
                _new_GroupID,
                GroupName,
                CreatedBy,
                CreatedDatetime,
                ModifiedBy,
                ModifiedDateTime,
                GroupStatus,
                _old_GroupID
            );
        }

        public void delete(long GroupID)
        {
            int count = m_db.SelectCount(@"select * from GroupMember where GroupID=@GroupID", GroupID);
            if (count == 0)
                throw new Exception("GroupMember.delete error. ID does not exists");

            m_db.Exec(@"delete from GroupMember where GroupID=@GroupID", GroupID);
        }

    }

    #endregion

    #region GroupMemberInResourcePermission
    //**********************************************************
    //  GroupMemberInResourcePermission
    //**********************************************************
    CMD_GroupMemberInResourcePermission m_GroupMemberInResourcePermission = null;
    public CMD_GroupMemberInResourcePermission GroupMemberInResourcePermission
    {
        get
        {
            if (m_GroupMemberInResourcePermission == null)
                m_GroupMemberInResourcePermission = new CMD_GroupMemberInResourcePermission(this);
            return m_GroupMemberInResourcePermission;
        }
    }

    [Serializable]
    public class TBL_GroupMemberInResourcePermission
    {
        public long GroupMemberID { get; set; }
        public long ResourceID { get; set; }
        public int Create0 { get; set; }
        public int Read0 { get; set; }
        public int Update0 { get; set; }
        public int Delete0 { get; set; }
        public int Status { get; set; }
        public long CreatedBy { get; set; }
        public DateTime CreatedDatetime { get; set; }
        public long ModifiedBy { get; set; }
        public DateTime ModifiedDateTime { get; set; }

        public TBL_GroupMemberInResourcePermission()
        {
            this.GroupMemberID = 0;
            this.ResourceID = 0;
            this.Create0 = 0;
            this.Read0 = 0;
            this.Update0 = 0;
            this.Delete0 = 0;
            this.Status = 0;
            this.CreatedBy = 0;
            this.CreatedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
            this.ModifiedBy = 0;
            this.ModifiedDateTime = Convert.ToDateTime("1900-01-01 00:00:00");
        }

        public TBL_GroupMemberInResourcePermission(long GroupMemberID, long ResourceID, int Create0, int Read0, int Update0, int Delete0, int Status, long CreatedBy, DateTime CreatedDatetime, long ModifiedBy, DateTime ModifiedDateTime)
        {
            this.GroupMemberID = GroupMemberID;
            this.ResourceID = ResourceID;
            this.Create0 = Create0;
            this.Read0 = Read0;
            this.Update0 = Update0;
            this.Delete0 = Delete0;
            this.Status = Status;
            this.CreatedBy = CreatedBy;
            this.CreatedDatetime = CreatedDatetime;
            this.ModifiedBy = ModifiedBy;
            this.ModifiedDateTime = ModifiedDateTime;
        }

        public void CopyTo(ref TBL_GroupMemberInResourcePermission to)
        {
            to.GroupMemberID = this.GroupMemberID;
            to.ResourceID = this.ResourceID;
            to.Create0 = this.Create0;
            to.Read0 = this.Read0;
            to.Update0 = this.Update0;
            to.Delete0 = this.Delete0;
            to.Status = this.Status;
            to.CreatedBy = this.CreatedBy;
            to.CreatedDatetime = this.CreatedDatetime;
            to.ModifiedBy = this.ModifiedBy;
            to.ModifiedDateTime = this.ModifiedDateTime;
        }

        public bool IsSame(TBL_GroupMemberInResourcePermission x)
        {
            return (
                this.GroupMemberID == x.GroupMemberID &&
                this.ResourceID == x.ResourceID &&
                this.Create0 == x.Create0 &&
                this.Read0 == x.Read0 &&
                this.Update0 == x.Update0 &&
                this.Delete0 == x.Delete0 &&
                this.Status == x.Status &&
                this.CreatedBy == x.CreatedBy &&
                this.CreatedDatetime == x.CreatedDatetime &&
                this.ModifiedBy == x.ModifiedBy &&
                this.ModifiedDateTime == x.ModifiedDateTime
            );
        }

        public static TBL_GroupMemberInResourcePermission ReadRow(DataRow row)
        {
            TBL_GroupMemberInResourcePermission record = new TBL_GroupMemberInResourcePermission();
            record.GroupMemberID = get_long_value(row["GroupMemberID"]);
            record.ResourceID = get_long_value(row["ResourceID"]);
            record.Create0 = get_int_value(row["Create0"]);
            record.Read0 = get_int_value(row["Read0"]);
            record.Update0 = get_int_value(row["Update0"]);
            record.Delete0 = get_int_value(row["Delete0"]);
            record.Status = get_int_value(row["Status"]);
            record.CreatedBy = get_long_value(row["CreatedBy"]);
            record.CreatedDatetime = get_DateTime_value(row["CreatedDatetime"]);
            record.ModifiedBy = get_long_value(row["ModifiedBy"]);
            record.ModifiedDateTime = get_DateTime_value(row["ModifiedDateTime"]);
            return record;
        }

        public static List<TBL_GroupMemberInResourcePermission> ReadTable(DataTable dt)
        {
            List<TBL_GroupMemberInResourcePermission> records = new List<TBL_GroupMemberInResourcePermission>();
            foreach (DataRow row in dt.Rows)
                records.Add(ReadRow(row));
            return records;
        }
    }

    public class CMD_GroupMemberInResourcePermission
    {
        private MyLib.DAL_MSSQL m_db = null;

        public CMD_GroupMemberInResourcePermission(MyLib.DAL_MSSQL db)
        {
            m_db = db;
        }

        public DataTable select(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select GroupMemberID, ResourceID, Create0, Read0, Update0, Delete0, Status, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime
					from GroupMemberInResourcePermission
					" + where_clause, inputs);
        }

        public DataTable select()
        {
            return select("");
        }

        public DataTable selectPK(long GroupMemberID, long ResourceID)
        {
            return select(@"where GroupMemberID=@GroupMemberID and ResourceID=@ResourceID"
                , GroupMemberID, ResourceID);
        }

        public TBL_GroupMemberInResourcePermission select2(string where_clause, params object[] inputs)
        {
            DataTable dt = select(where_clause, inputs);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_GroupMemberInResourcePermission.ReadRow(dt.Rows[0]);
        }

        public TBL_GroupMemberInResourcePermission selectPK2(long GroupMemberID, long ResourceID)
        {
            DataTable dt = selectPK(GroupMemberID, ResourceID);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_GroupMemberInResourcePermission.ReadRow(dt.Rows[0]);
        }

        public DataTable select_join(long GroupMemberID, long ResourceID)
        {
            return select_join("where GroupMemberInResourcePermission.GroupMemberID=@GroupMemberID and GroupMemberInResourcePermission.ResourceID=@ResourceID", GroupMemberID, ResourceID);
        }

        public DataTable select_join()
        {
            return select_join("");
        }

        public DataTable select_join(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select GroupMemberInResourcePermission.GroupMemberID, GroupMemberInResourcePermission.ResourceID, GroupMemberInResourcePermission.Create0, GroupMemberInResourcePermission.Read0, GroupMemberInResourcePermission.Update0, GroupMemberInResourcePermission.Delete0, GroupMemberInResourcePermission.Status, GroupMemberInResourcePermission.CreatedBy, GroupMemberInResourcePermission.CreatedDatetime, GroupMemberInResourcePermission.ModifiedBy, GroupMemberInResourcePermission.ModifiedDateTime
					from GroupMemberInResourcePermission
					" + where_clause, inputs);
        }


        public void insert
        (
            long? GroupMemberID,
            long? ResourceID,
            int? Create0,
            int? Read0,
            int? Update0,
            int? Delete0,
            int? Status,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDateTime
        )
        {
            int count = m_db.SelectCount(@"select * from GroupMemberInResourcePermission where GroupMemberID=@GroupMemberID and ResourceID=@ResourceID", GroupMemberID, ResourceID);
            if (count > 0)
                throw new Exception("GroupMemberInResourcePermission.insert error. ID duplicate");

            m_db.Exec(@"
					insert into GroupMemberInResourcePermission(
						GroupMemberID,
						ResourceID,
						Create0,
						Read0,
						Update0,
						Delete0,
						Status,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDateTime
						)
					values(
						@GroupMemberID,
						@ResourceID,
						@Create0,
						@Read0,
						@Update0,
						@Delete0,
						@Status,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDateTime
						)
					", GroupMemberID, ResourceID, Create0, Read0, Update0, Delete0, Status, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime);
        }

        public void update
        (
            long _old_GroupMemberID,
            long _old_ResourceID,
            long _new_GroupMemberID,
            long _new_ResourceID,
            int? Create0,
            int? Read0,
            int? Update0,
            int? Delete0,
            int? Status,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDateTime
        )
        {
            int count = m_db.SelectCount(@"select * from GroupMemberInResourcePermission where GroupMemberID=@_old_GroupMemberID and ResourceID=@_old_ResourceID", _old_GroupMemberID, _old_ResourceID);
            if (count == 0)
                throw new Exception("GroupMemberInResourcePermission.update error. ID does not exists");

            m_db.Exec(@"
					update GroupMemberInResourcePermission
					set
						GroupMemberID = @_new_GroupMemberID,
						ResourceID = @_new_ResourceID,
						Create0 = @Create0,
						Read0 = @Read0,
						Update0 = @Update0,
						Delete0 = @Delete0,
						Status = @Status,
						CreatedBy = @CreatedBy,
						CreatedDatetime = @CreatedDatetime,
						ModifiedBy = @ModifiedBy,
						ModifiedDateTime = @ModifiedDateTime
					where GroupMemberID=@_old_GroupMemberID and ResourceID=@_old_ResourceID
					",
                _new_GroupMemberID,
                _new_ResourceID,
                Create0,
                Read0,
                Update0,
                Delete0,
                Status,
                CreatedBy,
                CreatedDatetime,
                ModifiedBy,
                ModifiedDateTime,
                _old_GroupMemberID,
                _old_ResourceID
            );
        }

        public void delete(long GroupMemberID, long ResourceID)
        {
            int count = m_db.SelectCount(@"select * from GroupMemberInResourcePermission where GroupMemberID=@GroupMemberID and ResourceID=@ResourceID", GroupMemberID, ResourceID);
            if (count == 0)
                throw new Exception("GroupMemberInResourcePermission.delete error. ID does not exists");

            m_db.Exec(@"delete from GroupMemberInResourcePermission where GroupMemberID=@GroupMemberID and ResourceID=@ResourceID", GroupMemberID, ResourceID);
        }

    }

    #endregion

    #region Notice
    //**********************************************************
    //  Notice
    //**********************************************************
    CMD_Notice m_Notice = null;
    public CMD_Notice Notice
    {
        get
        {
            if (m_Notice == null)
                m_Notice = new CMD_Notice(this);
            return m_Notice;
        }
    }

    [Serializable]
    public class TBL_Notice
    {
        public long ID { get; set; }
        public string Subject { get; set; }
        public string Body0 { get; set; }
        public DateTime PublishDate { get; set; }
        public DateTime ExpiredDate { get; set; }
        public long CreatedBy { get; set; }
        public DateTime CreatedDatetime { get; set; }
        public long ModifiedBy { get; set; }
        public DateTime ModifiedDatetime { get; set; }

        public TBL_Notice()
        {
            this.ID = 0;
            this.Subject = "";
            this.Body0 = "";
            this.PublishDate = Convert.ToDateTime("1900-01-01 00:00:00");
            this.ExpiredDate = Convert.ToDateTime("1900-01-01 00:00:00");
            this.CreatedBy = 0;
            this.CreatedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
            this.ModifiedBy = 0;
            this.ModifiedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
        }

        public TBL_Notice(long ID, string Subject, string Body0, DateTime PublishDate, DateTime ExpiredDate, long CreatedBy, DateTime CreatedDatetime, long ModifiedBy, DateTime ModifiedDatetime)
        {
            this.ID = ID;
            this.Subject = Subject;
            this.Body0 = Body0;
            this.PublishDate = PublishDate;
            this.ExpiredDate = ExpiredDate;
            this.CreatedBy = CreatedBy;
            this.CreatedDatetime = CreatedDatetime;
            this.ModifiedBy = ModifiedBy;
            this.ModifiedDatetime = ModifiedDatetime;
        }

        public void CopyTo(ref TBL_Notice to)
        {
            to.ID = this.ID;
            to.Subject = this.Subject;
            to.Body0 = this.Body0;
            to.PublishDate = this.PublishDate;
            to.ExpiredDate = this.ExpiredDate;
            to.CreatedBy = this.CreatedBy;
            to.CreatedDatetime = this.CreatedDatetime;
            to.ModifiedBy = this.ModifiedBy;
            to.ModifiedDatetime = this.ModifiedDatetime;
        }

        public bool IsSame(TBL_Notice x)
        {
            return (
                this.ID == x.ID &&
                this.Subject == x.Subject &&
                this.Body0 == x.Body0 &&
                this.PublishDate == x.PublishDate &&
                this.ExpiredDate == x.ExpiredDate &&
                this.CreatedBy == x.CreatedBy &&
                this.CreatedDatetime == x.CreatedDatetime &&
                this.ModifiedBy == x.ModifiedBy &&
                this.ModifiedDatetime == x.ModifiedDatetime
            );
        }

        public static TBL_Notice ReadRow(DataRow row)
        {
            TBL_Notice record = new TBL_Notice();
            record.ID = get_long_value(row["ID"]);
            record.Subject = get_string_value(row["Subject"]);
            record.Body0 = get_string_value(row["Body0"]);
            record.PublishDate = get_DateTime_value(row["PublishDate"]);
            record.ExpiredDate = get_DateTime_value(row["ExpiredDate"]);
            record.CreatedBy = get_long_value(row["CreatedBy"]);
            record.CreatedDatetime = get_DateTime_value(row["CreatedDatetime"]);
            record.ModifiedBy = get_long_value(row["ModifiedBy"]);
            record.ModifiedDatetime = get_DateTime_value(row["ModifiedDatetime"]);
            return record;
        }

        public static List<TBL_Notice> ReadTable(DataTable dt)
        {
            List<TBL_Notice> records = new List<TBL_Notice>();
            foreach (DataRow row in dt.Rows)
                records.Add(ReadRow(row));
            return records;
        }
    }

    public class CMD_Notice
    {
        private MyLib.DAL_MSSQL m_db = null;

        public CMD_Notice(MyLib.DAL_MSSQL db)
        {
            m_db = db;
        }

        public DataTable select(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select ID, Subject, Body0, PublishDate, ExpiredDate, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDatetime
					from Notice
					" + where_clause, inputs);
        }

        public DataTable select()
        {
            return select("");
        }

        public DataTable selectPK(long ID)
        {
            return select(@"where ID=@ID"
                , ID);
        }

        public TBL_Notice select2(string where_clause, params object[] inputs)
        {
            DataTable dt = select(where_clause, inputs);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_Notice.ReadRow(dt.Rows[0]);
        }

        public TBL_Notice selectPK2(long ID)
        {
            DataTable dt = selectPK(ID);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_Notice.ReadRow(dt.Rows[0]);
        }

        public DataTable select_join(long ID)
        {
            return select_join("where Notice.ID=@ID", ID);
        }

        public DataTable select_join()
        {
            return select_join("");
        }

        public DataTable select_join(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select Notice.ID, Notice.Subject, Notice.Body0, Notice.PublishDate, Notice.ExpiredDate, Notice.CreatedBy, Notice.CreatedDatetime, Notice.ModifiedBy, Notice.ModifiedDatetime
					from Notice
					" + where_clause, inputs);
        }

        public void insert
        (
            ref long? ID,
            string Subject,
            string Body0,
            DateTime? PublishDate,
            DateTime? ExpiredDate,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDatetime
        )
        {

            m_db.Exec(@"
					insert into Notice(
						Subject,
						Body0,
						PublishDate,
						ExpiredDate,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDatetime
						)
					values(
						@Subject,
						@Body0,
						@PublishDate,
						@ExpiredDate,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDatetime
						)
					", Subject, Body0, PublishDate, ExpiredDate, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDatetime);

            ID = m_db.SelectInt("select IDENT_CURRENT('Notice')");
        }

        public void insert
        (
            string Subject,
            string Body0,
            DateTime? PublishDate,
            DateTime? ExpiredDate,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDatetime
        )
        {
            m_db.Exec(@"
					insert into Notice(
						Subject,
						Body0,
						PublishDate,
						ExpiredDate,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDatetime
						)
					values(
						@Subject,
						@Body0,
						@PublishDate,
						@ExpiredDate,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDatetime
						)
					", Subject, Body0, PublishDate, ExpiredDate, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDatetime);
        }

        public void update
        (
            long ID,
            string Subject,
            string Body0,
            DateTime? PublishDate,
            DateTime? ExpiredDate,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDatetime
        )
        {
            int count = m_db.SelectCount(@"select * from Notice where ID=@ID", ID);
            if (count == 0)
                throw new Exception("Notice.update error. ID does not exists");

            m_db.Exec(@"
					update Notice
					set
						Subject = @Subject,
						Body0 = @Body0,
						PublishDate = @PublishDate,
						ExpiredDate = @ExpiredDate,
						CreatedBy = @CreatedBy,
						CreatedDatetime = @CreatedDatetime,
						ModifiedBy = @ModifiedBy,
						ModifiedDatetime = @ModifiedDatetime
					where ID=@ID
					",
                Subject,
                Body0,
                PublishDate,
                ExpiredDate,
                CreatedBy,
                CreatedDatetime,
                ModifiedBy,
                ModifiedDatetime,
                ID
            );
        }

        public void delete(long ID)
        {
            int count = m_db.SelectCount(@"select * from Notice where ID=@ID", ID);
            if (count == 0)
                throw new Exception("Notice.delete error. ID does not exists");

            m_db.Exec(@"delete from Notice where ID=@ID", ID);
        }

    }

    #endregion

    #region Organization
    //**********************************************************
    //  Organization
    //**********************************************************
    CMD_Organization m_Organization = null;
    public CMD_Organization Organization
    {
        get
        {
            if (m_Organization == null)
                m_Organization = new CMD_Organization(this);
            return m_Organization;
        }
    }

    [Serializable]
    public class TBL_Organization
    {
        public long ID { get; set; }
        public string OrgIDName { get; set; }
        public string OrgName { get; set; }
        public int IsMinistry { get; set; }
        public int OrgStatus { get; set; }
        public long CreatedBy { get; set; }
        public DateTime CreatedDatetime { get; set; }
        public long ModifiedBy { get; set; }
        public DateTime ModifiedDateTime { get; set; }

        public TBL_Organization()
        {
            this.ID = 0;
            this.OrgIDName = "";
            this.OrgName = "";
            this.IsMinistry = 0;
            this.OrgStatus = 0;
            this.CreatedBy = 0;
            this.CreatedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
            this.ModifiedBy = 0;
            this.ModifiedDateTime = Convert.ToDateTime("1900-01-01 00:00:00");
        }

        public TBL_Organization(long ID, string OrgIDName, string OrgName, int IsMinistry, int OrgStatus, long CreatedBy, DateTime CreatedDatetime, long ModifiedBy, DateTime ModifiedDateTime)
        {
            this.ID = ID;
            this.OrgIDName = OrgIDName;
            this.OrgName = OrgName;
            this.IsMinistry = IsMinistry;
            this.OrgStatus = OrgStatus;
            this.CreatedBy = CreatedBy;
            this.CreatedDatetime = CreatedDatetime;
            this.ModifiedBy = ModifiedBy;
            this.ModifiedDateTime = ModifiedDateTime;
        }

        public void CopyTo(ref TBL_Organization to)
        {
            to.ID = this.ID;
            to.OrgIDName = this.OrgIDName;
            to.OrgName = this.OrgName;
            to.IsMinistry = this.IsMinistry;
            to.OrgStatus = this.OrgStatus;
            to.CreatedBy = this.CreatedBy;
            to.CreatedDatetime = this.CreatedDatetime;
            to.ModifiedBy = this.ModifiedBy;
            to.ModifiedDateTime = this.ModifiedDateTime;
        }

        public bool IsSame(TBL_Organization x)
        {
            return (
                this.ID == x.ID &&
                this.OrgIDName == x.OrgIDName &&
                this.OrgName == x.OrgName &&
                this.IsMinistry == x.IsMinistry &&
                this.OrgStatus == x.OrgStatus &&
                this.CreatedBy == x.CreatedBy &&
                this.CreatedDatetime == x.CreatedDatetime &&
                this.ModifiedBy == x.ModifiedBy &&
                this.ModifiedDateTime == x.ModifiedDateTime
            );
        }

        public static TBL_Organization ReadRow(DataRow row)
        {
            TBL_Organization record = new TBL_Organization();
            record.ID = get_long_value(row["ID"]);
            record.OrgIDName = get_string_value(row["OrgIDName"]);
            record.OrgName = get_string_value(row["OrgName"]);
            record.IsMinistry = get_int_value(row["IsMinistry"]);
            record.OrgStatus = get_int_value(row["OrgStatus"]);
            record.CreatedBy = get_long_value(row["CreatedBy"]);
            record.CreatedDatetime = get_DateTime_value(row["CreatedDatetime"]);
            record.ModifiedBy = get_long_value(row["ModifiedBy"]);
            record.ModifiedDateTime = get_DateTime_value(row["ModifiedDateTime"]);
            return record;
        }

        public static List<TBL_Organization> ReadTable(DataTable dt)
        {
            List<TBL_Organization> records = new List<TBL_Organization>();
            foreach (DataRow row in dt.Rows)
                records.Add(ReadRow(row));
            return records;
        }
    }

    public class CMD_Organization
    {
        private MyLib.DAL_MSSQL m_db = null;

        public CMD_Organization(MyLib.DAL_MSSQL db)
        {
            m_db = db;
        }

        public DataTable select(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select ID, OrgIDName, OrgName, IsMinistry, OrgStatus, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime
					from Organization
					" + where_clause, inputs);
        }

        public DataTable select()
        {
            return select("");
        }

        public DataTable selectPK(long ID)
        {
            return select(@"where ID=@ID"
                , ID);
        }

        public TBL_Organization select2(string where_clause, params object[] inputs)
        {
            DataTable dt = select(where_clause, inputs);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_Organization.ReadRow(dt.Rows[0]);
        }

        public TBL_Organization selectPK2(long ID)
        {
            DataTable dt = selectPK(ID);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_Organization.ReadRow(dt.Rows[0]);
        }

        public DataTable select_join(long ID)
        {
            return select_join("where Organization.ID=@ID", ID);
        }

        public DataTable select_join()
        {
            return select_join("");
        }

        public DataTable select_join(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select Organization.ID, Organization.OrgIDName, Organization.OrgName, Organization.IsMinistry, Organization.OrgStatus, Organization.CreatedBy, Organization.CreatedDatetime, Organization.ModifiedBy, Organization.ModifiedDateTime
					from Organization
					" + where_clause, inputs);
        }

        public void insert
        (
            ref long? ID,
            string OrgIDName,
            string OrgName,
            int? IsMinistry,
            int? OrgStatus,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDateTime
        )
        {

            m_db.Exec(@"
					insert into Organization(
						OrgIDName,
						OrgName,
						IsMinistry,
						OrgStatus,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDateTime
						)
					values(
						@OrgIDName,
						@OrgName,
						@IsMinistry,
						@OrgStatus,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDateTime
						)
					", OrgIDName, OrgName, IsMinistry, OrgStatus, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime);

            ID = m_db.SelectInt("select IDENT_CURRENT('Organization')");
        }

        public void insert
        (
            string OrgIDName,
            string OrgName,
            int? IsMinistry,
            int? OrgStatus,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDateTime
        )
        {
            m_db.Exec(@"
					insert into Organization(
						OrgIDName,
						OrgName,
						IsMinistry,
						OrgStatus,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDateTime
						)
					values(
						@OrgIDName,
						@OrgName,
						@IsMinistry,
						@OrgStatus,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDateTime
						)
					", OrgIDName, OrgName, IsMinistry, OrgStatus, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime);
        }

        public void update
        (
            long ID,
            string OrgIDName,
            string OrgName,
            int? IsMinistry,
            int? OrgStatus,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDateTime
        )
        {
            int count = m_db.SelectCount(@"select * from Organization where ID=@ID", ID);
            if (count == 0)
                throw new Exception("Organization.update error. ID does not exists");

            m_db.Exec(@"
					update Organization
					set
						OrgIDName = @OrgIDName,
						OrgName = @OrgName,
						IsMinistry = @IsMinistry,
						OrgStatus = @OrgStatus,
						CreatedBy = @CreatedBy,
						CreatedDatetime = @CreatedDatetime,
						ModifiedBy = @ModifiedBy,
						ModifiedDateTime = @ModifiedDateTime
					where ID=@ID
					",
                OrgIDName,
                OrgName,
                IsMinistry,
                OrgStatus,
                CreatedBy,
                CreatedDatetime,
                ModifiedBy,
                ModifiedDateTime,
                ID
            );
        }

        public void delete(long ID)
        {
            int count = m_db.SelectCount(@"select * from Organization where ID=@ID", ID);
            if (count == 0)
                throw new Exception("Organization.delete error. ID does not exists");

            m_db.Exec(@"delete from Organization where ID=@ID", ID);
        }

    }

    #endregion

    #region ReasonsInChangeRequest
    //**********************************************************
    //  ReasonsInChangeRequest
    //**********************************************************
    CMD_ReasonsInChangeRequest m_ReasonsInChangeRequest = null;
    public CMD_ReasonsInChangeRequest ReasonsInChangeRequest
    {
        get
        {
            if (m_ReasonsInChangeRequest == null)
                m_ReasonsInChangeRequest = new CMD_ReasonsInChangeRequest(this);
            return m_ReasonsInChangeRequest;
        }
    }

    [Serializable]
    public class TBL_ReasonsInChangeRequest
    {
        public long ID { get; set; }
        public long ChangeRequestID { get; set; }
        public long ChangeRequestReasonID { get; set; }

        public TBL_ReasonsInChangeRequest()
        {
            this.ID = 0;
            this.ChangeRequestID = 0;
            this.ChangeRequestReasonID = 0;
        }

        public TBL_ReasonsInChangeRequest(long ID, long ChangeRequestID, long ChangeRequestReasonID)
        {
            this.ID = ID;
            this.ChangeRequestID = ChangeRequestID;
            this.ChangeRequestReasonID = ChangeRequestReasonID;
        }

        public void CopyTo(ref TBL_ReasonsInChangeRequest to)
        {
            to.ID = this.ID;
            to.ChangeRequestID = this.ChangeRequestID;
            to.ChangeRequestReasonID = this.ChangeRequestReasonID;
        }

        public bool IsSame(TBL_ReasonsInChangeRequest x)
        {
            return (
                this.ID == x.ID &&
                this.ChangeRequestID == x.ChangeRequestID &&
                this.ChangeRequestReasonID == x.ChangeRequestReasonID
            );
        }

        public static TBL_ReasonsInChangeRequest ReadRow(DataRow row)
        {
            TBL_ReasonsInChangeRequest record = new TBL_ReasonsInChangeRequest();
            record.ID = get_long_value(row["ID"]);
            record.ChangeRequestID = get_long_value(row["ChangeRequestID"]);
            record.ChangeRequestReasonID = get_long_value(row["ChangeRequestReasonID"]);
            return record;
        }

        public static List<TBL_ReasonsInChangeRequest> ReadTable(DataTable dt)
        {
            List<TBL_ReasonsInChangeRequest> records = new List<TBL_ReasonsInChangeRequest>();
            foreach (DataRow row in dt.Rows)
                records.Add(ReadRow(row));
            return records;
        }
    }

    public class CMD_ReasonsInChangeRequest
    {
        private MyLib.DAL_MSSQL m_db = null;

        public CMD_ReasonsInChangeRequest(MyLib.DAL_MSSQL db)
        {
            m_db = db;
        }

        public DataTable select(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select ID, ChangeRequestID, ChangeRequestReasonID
					from ReasonsInChangeRequest
					" + where_clause, inputs);
        }

        public DataTable select()
        {
            return select("");
        }

        public DataTable selectPK(long ID)
        {
            return select(@"where ID=@ID"
                , ID);
        }

        public TBL_ReasonsInChangeRequest select2(string where_clause, params object[] inputs)
        {
            DataTable dt = select(where_clause, inputs);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_ReasonsInChangeRequest.ReadRow(dt.Rows[0]);
        }

        public TBL_ReasonsInChangeRequest selectPK2(long ID)
        {
            DataTable dt = selectPK(ID);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_ReasonsInChangeRequest.ReadRow(dt.Rows[0]);
        }

        public DataTable select_join(long ID)
        {
            return select_join("where ReasonsInChangeRequest.ID=@ID", ID);
        }

        public DataTable select_join()
        {
            return select_join("");
        }

        public DataTable select_join(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select ReasonsInChangeRequest.ID, ReasonsInChangeRequest.ChangeRequestID, ReasonsInChangeRequest.ChangeRequestReasonID
					from ReasonsInChangeRequest
					" + where_clause, inputs);
        }

        public void insert
        (
            ref long? ID,
            long? ChangeRequestID,
            long? ChangeRequestReasonID
        )
        {

            m_db.Exec(@"
					insert into ReasonsInChangeRequest(
						ChangeRequestID,
						ChangeRequestReasonID
						)
					values(
						@ChangeRequestID,
						@ChangeRequestReasonID
						)
					", ChangeRequestID, ChangeRequestReasonID);

            ID = m_db.SelectInt("select IDENT_CURRENT('ReasonsInChangeRequest')");
        }

        public void insert
        (
            long? ChangeRequestID,
            long? ChangeRequestReasonID
        )
        {
            m_db.Exec(@"
					insert into ReasonsInChangeRequest(
						ChangeRequestID,
						ChangeRequestReasonID
						)
					values(
						@ChangeRequestID,
						@ChangeRequestReasonID
						)
					", ChangeRequestID, ChangeRequestReasonID);
        }

        public void update
        (
            long ID,
            long? ChangeRequestID,
            long? ChangeRequestReasonID
        )
        {
            int count = m_db.SelectCount(@"select * from ReasonsInChangeRequest where ID=@ID", ID);
            if (count == 0)
                throw new Exception("ReasonsInChangeRequest.update error. ID does not exists");

            m_db.Exec(@"
					update ReasonsInChangeRequest
					set
						ChangeRequestID = @ChangeRequestID,
						ChangeRequestReasonID = @ChangeRequestReasonID
					where ID=@ID
					",
                ChangeRequestID,
                ChangeRequestReasonID,
                ID
            );
        }

        public void delete(long ID)
        {
            int count = m_db.SelectCount(@"select * from ReasonsInChangeRequest where ID=@ID", ID);
            if (count == 0)
                throw new Exception("ReasonsInChangeRequest.delete error. ID does not exists");

            m_db.Exec(@"delete from ReasonsInChangeRequest where ID=@ID", ID);
        }

    }

    #endregion

    #region ResourceMenu
    //**********************************************************
    //  ResourceMenu
    //**********************************************************
    CMD_ResourceMenu m_ResourceMenu = null;
    public CMD_ResourceMenu ResourceMenu
    {
        get
        {
            if (m_ResourceMenu == null)
                m_ResourceMenu = new CMD_ResourceMenu(this);
            return m_ResourceMenu;
        }
    }

    [Serializable]
    public class TBL_ResourceMenu
    {
        public long ID { get; set; }
        public long Parent { get; set; }
        public string ResourceName { get; set; }
        public string PageURL { get; set; }
        public int Status { get; set; }
        public long CreatedBy { get; set; }
        public DateTime CreatedDatetime { get; set; }
        public long ModifiedBy { get; set; }
        public DateTime ModifiedDateTime { get; set; }
        public int PageOrder { get; set; }

        public TBL_ResourceMenu()
        {
            this.ID = 0;
            this.Parent = 0;
            this.ResourceName = "";
            this.PageURL = "";
            this.Status = 0;
            this.CreatedBy = 0;
            this.CreatedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
            this.ModifiedBy = 0;
            this.ModifiedDateTime = Convert.ToDateTime("1900-01-01 00:00:00");
            this.PageOrder = 0;
        }

        public TBL_ResourceMenu(long ID, long Parent, string ResourceName, string PageURL, int Status, long CreatedBy, DateTime CreatedDatetime, long ModifiedBy, DateTime ModifiedDateTime, int PageOrder)
        {
            this.ID = ID;
            this.Parent = Parent;
            this.ResourceName = ResourceName;
            this.PageURL = PageURL;
            this.Status = Status;
            this.CreatedBy = CreatedBy;
            this.CreatedDatetime = CreatedDatetime;
            this.ModifiedBy = ModifiedBy;
            this.ModifiedDateTime = ModifiedDateTime;
            this.PageOrder = PageOrder;
        }

        public void CopyTo(ref TBL_ResourceMenu to)
        {
            to.ID = this.ID;
            to.Parent = this.Parent;
            to.ResourceName = this.ResourceName;
            to.PageURL = this.PageURL;
            to.Status = this.Status;
            to.CreatedBy = this.CreatedBy;
            to.CreatedDatetime = this.CreatedDatetime;
            to.ModifiedBy = this.ModifiedBy;
            to.ModifiedDateTime = this.ModifiedDateTime;
            to.PageOrder = this.PageOrder;
        }

        public bool IsSame(TBL_ResourceMenu x)
        {
            return (
                this.ID == x.ID &&
                this.Parent == x.Parent &&
                this.ResourceName == x.ResourceName &&
                this.PageURL == x.PageURL &&
                this.Status == x.Status &&
                this.CreatedBy == x.CreatedBy &&
                this.CreatedDatetime == x.CreatedDatetime &&
                this.ModifiedBy == x.ModifiedBy &&
                this.ModifiedDateTime == x.ModifiedDateTime &&
                this.PageOrder == x.PageOrder
            );
        }

        public static TBL_ResourceMenu ReadRow(DataRow row)
        {
            TBL_ResourceMenu record = new TBL_ResourceMenu();
            record.ID = get_long_value(row["ID"]);
            record.Parent = get_long_value(row["Parent"]);
            record.ResourceName = get_string_value(row["ResourceName"]);
            record.PageURL = get_string_value(row["PageURL"]);
            record.Status = get_int_value(row["Status"]);
            record.CreatedBy = get_long_value(row["CreatedBy"]);
            record.CreatedDatetime = get_DateTime_value(row["CreatedDatetime"]);
            record.ModifiedBy = get_long_value(row["ModifiedBy"]);
            record.ModifiedDateTime = get_DateTime_value(row["ModifiedDateTime"]);
            record.PageOrder = get_int_value(row["PageOrder"]);
            return record;
        }

        public static List<TBL_ResourceMenu> ReadTable(DataTable dt)
        {
            List<TBL_ResourceMenu> records = new List<TBL_ResourceMenu>();
            foreach (DataRow row in dt.Rows)
                records.Add(ReadRow(row));
            return records;
        }
    }

    public class CMD_ResourceMenu
    {
        private MyLib.DAL_MSSQL m_db = null;

        public CMD_ResourceMenu(MyLib.DAL_MSSQL db)
        {
            m_db = db;
        }

        public DataTable select(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select ID, Parent, ResourceName, PageURL, Status, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime, PageOrder
					from ResourceMenu
					" + where_clause, inputs);
        }

        public DataTable select()
        {
            return select("");
        }

        public DataTable selectPK(long ID)
        {
            return select(@"where ID=@ID"
                , ID);
        }

        public TBL_ResourceMenu select2(string where_clause, params object[] inputs)
        {
            DataTable dt = select(where_clause, inputs);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_ResourceMenu.ReadRow(dt.Rows[0]);
        }

        public TBL_ResourceMenu selectPK2(long ID)
        {
            DataTable dt = selectPK(ID);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_ResourceMenu.ReadRow(dt.Rows[0]);
        }

        public DataTable select_join(long ID)
        {
            return select_join("where ResourceMenu.ID=@ID", ID);
        }

        public DataTable select_join()
        {
            return select_join("");
        }

        public DataTable select_join(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select ResourceMenu.ID, ResourceMenu.Parent, ResourceMenu.ResourceName, ResourceMenu.PageURL, ResourceMenu.Status, ResourceMenu.CreatedBy, ResourceMenu.CreatedDatetime, ResourceMenu.ModifiedBy, ResourceMenu.ModifiedDateTime, ResourceMenu.PageOrder
					from ResourceMenu
					" + where_clause, inputs);
        }

        public void insert
        (
            ref long? ID,
            long? Parent,
            string ResourceName,
            string PageURL,
            int? Status,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDateTime,
            int? PageOrder
        )
        {

            m_db.Exec(@"
					insert into ResourceMenu(
						Parent,
						ResourceName,
						PageURL,
						Status,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDateTime,
						PageOrder
						)
					values(
						@Parent,
						@ResourceName,
						@PageURL,
						@Status,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDateTime,
						@PageOrder
						)
					", Parent, ResourceName, PageURL, Status, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime, PageOrder);

            ID = m_db.SelectInt("select IDENT_CURRENT('ResourceMenu')");
        }

        public void insert
        (
            long? Parent,
            string ResourceName,
            string PageURL,
            int? Status,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDateTime,
            int? PageOrder
        )
        {
            m_db.Exec(@"
					insert into ResourceMenu(
						Parent,
						ResourceName,
						PageURL,
						Status,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDateTime,
						PageOrder
						)
					values(
						@Parent,
						@ResourceName,
						@PageURL,
						@Status,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDateTime,
						@PageOrder
						)
					", Parent, ResourceName, PageURL, Status, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime, PageOrder);
        }

        public void update
        (
            long ID,
            long? Parent,
            string ResourceName,
            string PageURL,
            int? Status,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDateTime,
            int? PageOrder
        )
        {
            int count = m_db.SelectCount(@"select * from ResourceMenu where ID=@ID", ID);
            if (count == 0)
                throw new Exception("ResourceMenu.update error. ID does not exists");

            m_db.Exec(@"
					update ResourceMenu
					set
						Parent = @Parent,
						ResourceName = @ResourceName,
						PageURL = @PageURL,
						Status = @Status,
						CreatedBy = @CreatedBy,
						CreatedDatetime = @CreatedDatetime,
						ModifiedBy = @ModifiedBy,
						ModifiedDateTime = @ModifiedDateTime,
						PageOrder = @PageOrder
					where ID=@ID
					",
                Parent,
                ResourceName,
                PageURL,
                Status,
                CreatedBy,
                CreatedDatetime,
                ModifiedBy,
                ModifiedDateTime,
                PageOrder,
                ID
            );
        }

        public void delete(long ID)
        {
            int count = m_db.SelectCount(@"select * from ResourceMenu where ID=@ID", ID);
            if (count == 0)
                throw new Exception("ResourceMenu.delete error. ID does not exists");

            m_db.Exec(@"delete from ResourceMenu where ID=@ID", ID);
        }

    }

    #endregion

    #region ServiceForm
    //**********************************************************
    //  ServiceForm
    //**********************************************************
    CMD_ServiceForm m_ServiceForm = null;
    public CMD_ServiceForm ServiceForm
    {
        get
        {
            if (m_ServiceForm == null)
                m_ServiceForm = new CMD_ServiceForm(this);
            return m_ServiceForm;
        }
    }

    [Serializable]
    public class TBL_ServiceForm
    {
        public long ID { get; set; }
        public string SRUniqueID { get; set; }
        public string DraftName { get; set; }
        public long SRType { get; set; }
        public long ToSiteID { get; set; }
        public long ToCostCentreID { get; set; }
        public long CostCentreId { get; set; }
        public long SRStatus { get; set; }
        public string Remarks { get; set; }
        public long CreatedBy { get; set; }
        public DateTime CreatedDatetime { get; set; }
        public long SubmitedBy { get; set; }
        public DateTime SubmitedDatetime { get; set; }
        public long ModifiedBy { get; set; }
        public DateTime ModifiedDatetime { get; set; }
        public long CloseBy { get; set; }
        public DateTime CloseDatetime { get; set; }
        public long CancelBy { get; set; }
        public DateTime CancelDatetime { get; set; }
        public long RejectBy { get; set; }
        public DateTime RejectDatetime { get; set; }
        public long ParentUniqueSRID { get; set; }
        public int IsUrgent { get; set; }
        public DateTime AckDatetime { get; set; }
        public long AckBy { get; set; }
        public DateTime EffectiveDate { get; set; }

        public TBL_ServiceForm()
        {
            this.ID = 0;
            this.SRUniqueID = "";
            this.DraftName = "";
            this.SRType = 0;
            this.ToSiteID = 0;
            this.ToCostCentreID = 0;
            this.CostCentreId = 0;
            this.SRStatus = 0;
            this.Remarks = "";
            this.CreatedBy = 0;
            this.CreatedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
            this.SubmitedBy = 0;
            this.SubmitedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
            this.ModifiedBy = 0;
            this.ModifiedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
            this.CloseBy = 0;
            this.CloseDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
            this.CancelBy = 0;
            this.CancelDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
            this.RejectBy = 0;
            this.RejectDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
            this.ParentUniqueSRID = 0;
            this.IsUrgent = 0;
            this.AckDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
            this.AckBy = 0;
            this.EffectiveDate = Convert.ToDateTime("1900-01-01 00:00:00");
        }

        public TBL_ServiceForm(long ID, string SRUniqueID, string DraftName, long SRType, long ToSiteID, long ToCostCentreID, long CostCentreId, long SRStatus, string Remarks, long CreatedBy, DateTime CreatedDatetime, long SubmitedBy, DateTime SubmitedDatetime, long ModifiedBy, DateTime ModifiedDatetime, long CloseBy, DateTime CloseDatetime, long CancelBy, DateTime CancelDatetime, long RejectBy, DateTime RejectDatetime, long ParentUniqueSRID, int IsUrgent, DateTime AckDatetime, long AckBy, DateTime EffectiveDate)
        {
            this.ID = ID;
            this.SRUniqueID = SRUniqueID;
            this.DraftName = DraftName;
            this.SRType = SRType;
            this.ToSiteID = ToSiteID;
            this.ToCostCentreID = ToCostCentreID;
            this.CostCentreId = CostCentreId;
            this.SRStatus = SRStatus;
            this.Remarks = Remarks;
            this.CreatedBy = CreatedBy;
            this.CreatedDatetime = CreatedDatetime;
            this.SubmitedBy = SubmitedBy;
            this.SubmitedDatetime = SubmitedDatetime;
            this.ModifiedBy = ModifiedBy;
            this.ModifiedDatetime = ModifiedDatetime;
            this.CloseBy = CloseBy;
            this.CloseDatetime = CloseDatetime;
            this.CancelBy = CancelBy;
            this.CancelDatetime = CancelDatetime;
            this.RejectBy = RejectBy;
            this.RejectDatetime = RejectDatetime;
            this.ParentUniqueSRID = ParentUniqueSRID;
            this.IsUrgent = IsUrgent;
            this.AckDatetime = AckDatetime;
            this.AckBy = AckBy;
            this.EffectiveDate = EffectiveDate;
        }

        public void CopyTo(ref TBL_ServiceForm to)
        {
            to.ID = this.ID;
            to.SRUniqueID = this.SRUniqueID;
            to.DraftName = this.DraftName;
            to.SRType = this.SRType;
            to.ToSiteID = this.ToSiteID;
            to.ToCostCentreID = this.ToCostCentreID;
            to.CostCentreId = this.CostCentreId;
            to.SRStatus = this.SRStatus;
            to.Remarks = this.Remarks;
            to.CreatedBy = this.CreatedBy;
            to.CreatedDatetime = this.CreatedDatetime;
            to.SubmitedBy = this.SubmitedBy;
            to.SubmitedDatetime = this.SubmitedDatetime;
            to.ModifiedBy = this.ModifiedBy;
            to.ModifiedDatetime = this.ModifiedDatetime;
            to.CloseBy = this.CloseBy;
            to.CloseDatetime = this.CloseDatetime;
            to.CancelBy = this.CancelBy;
            to.CancelDatetime = this.CancelDatetime;
            to.RejectBy = this.RejectBy;
            to.RejectDatetime = this.RejectDatetime;
            to.ParentUniqueSRID = this.ParentUniqueSRID;
            to.IsUrgent = this.IsUrgent;
            to.AckDatetime = this.AckDatetime;
            to.AckBy = this.AckBy;
            to.EffectiveDate = this.EffectiveDate;
        }

        public bool IsSame(TBL_ServiceForm x)
        {
            return (
                this.ID == x.ID &&
                this.SRUniqueID == x.SRUniqueID &&
                this.DraftName == x.DraftName &&
                this.SRType == x.SRType &&
                this.ToSiteID == x.ToSiteID &&
                this.ToCostCentreID == x.ToCostCentreID &&
                this.CostCentreId == x.CostCentreId &&
                this.SRStatus == x.SRStatus &&
                this.Remarks == x.Remarks &&
                this.CreatedBy == x.CreatedBy &&
                this.CreatedDatetime == x.CreatedDatetime &&
                this.SubmitedBy == x.SubmitedBy &&
                this.SubmitedDatetime == x.SubmitedDatetime &&
                this.ModifiedBy == x.ModifiedBy &&
                this.ModifiedDatetime == x.ModifiedDatetime &&
                this.CloseBy == x.CloseBy &&
                this.CloseDatetime == x.CloseDatetime &&
                this.CancelBy == x.CancelBy &&
                this.CancelDatetime == x.CancelDatetime &&
                this.RejectBy == x.RejectBy &&
                this.RejectDatetime == x.RejectDatetime &&
                this.ParentUniqueSRID == x.ParentUniqueSRID &&
                this.IsUrgent == x.IsUrgent &&
                this.AckDatetime == x.AckDatetime &&
                this.AckBy == x.AckBy &&
                this.EffectiveDate == x.EffectiveDate
            );
        }

        public static TBL_ServiceForm ReadRow(DataRow row)
        {
            TBL_ServiceForm record = new TBL_ServiceForm();
            record.ID = get_long_value(row["ID"]);
            record.SRUniqueID = get_string_value(row["SRUniqueID"]);
            record.DraftName = get_string_value(row["DraftName"]);
            record.SRType = get_long_value(row["SRType"]);
            record.ToSiteID = get_long_value(row["ToSiteID"]);
            record.ToCostCentreID = get_long_value(row["ToCostCentreID"]);
            record.CostCentreId = get_long_value(row["CostCentreId"]);
            record.SRStatus = get_long_value(row["SRStatus"]);
            record.Remarks = get_string_value(row["Remarks"]);
            record.CreatedBy = get_long_value(row["CreatedBy"]);
            record.CreatedDatetime = get_DateTime_value(row["CreatedDatetime"]);
            record.SubmitedBy = get_long_value(row["SubmitedBy"]);
            record.SubmitedDatetime = get_DateTime_value(row["SubmitedDatetime"]);
            record.ModifiedBy = get_long_value(row["ModifiedBy"]);
            record.ModifiedDatetime = get_DateTime_value(row["ModifiedDatetime"]);
            record.CloseBy = get_long_value(row["CloseBy"]);
            record.CloseDatetime = get_DateTime_value(row["CloseDatetime"]);
            record.CancelBy = get_long_value(row["CancelBy"]);
            record.CancelDatetime = get_DateTime_value(row["CancelDatetime"]);
            record.RejectBy = get_long_value(row["RejectBy"]);
            record.RejectDatetime = get_DateTime_value(row["RejectDatetime"]);
            record.ParentUniqueSRID = get_long_value(row["ParentUniqueSRID"]);
            record.IsUrgent = get_int_value(row["IsUrgent"]);
            record.AckDatetime = get_DateTime_value(row["AckDatetime"]);
            record.AckBy = get_long_value(row["AckBy"]);
            record.EffectiveDate = get_DateTime_value(row["EffectiveDate"]);
            return record;
        }

        public static List<TBL_ServiceForm> ReadTable(DataTable dt)
        {
            List<TBL_ServiceForm> records = new List<TBL_ServiceForm>();
            foreach (DataRow row in dt.Rows)
                records.Add(ReadRow(row));
            return records;
        }
    }

    public class CMD_ServiceForm
    {
        private MyLib.DAL_MSSQL m_db = null;

        public CMD_ServiceForm(MyLib.DAL_MSSQL db)
        {
            m_db = db;
        }

        public DataTable select(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select ID, SRUniqueID, DraftName, SRType, ToSiteID, ToCostCentreID, CostCentreId, SRStatus, Remarks, CreatedBy, CreatedDatetime, SubmitedBy, SubmitedDatetime, ModifiedBy, ModifiedDatetime, CloseBy, CloseDatetime, CancelBy, CancelDatetime, RejectBy, RejectDatetime, ParentUniqueSRID, IsUrgent, AckDatetime, AckBy, EffectiveDate
					from ServiceForm
					" + where_clause, inputs);
        }

        public DataTable select()
        {
            return select("");
        }

        public DataTable selectPK(long ID)
        {
            return select(@"where ID=@ID"
                , ID);
        }

        public TBL_ServiceForm select2(string where_clause, params object[] inputs)
        {
            DataTable dt = select(where_clause, inputs);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_ServiceForm.ReadRow(dt.Rows[0]);
        }

        public TBL_ServiceForm selectPK2(long ID)
        {
            DataTable dt = selectPK(ID);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_ServiceForm.ReadRow(dt.Rows[0]);
        }

        public DataTable select_join(long ID)
        {
            return select_join("where ServiceForm.ID=@ID", ID);
        }

        public DataTable select_join()
        {
            return select_join("");
        }

        public DataTable select_join(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select ServiceForm.ID, ServiceForm.SRUniqueID, ServiceForm.DraftName, ServiceForm.SRType, ServiceForm.ToSiteID, ServiceForm.ToCostCentreID, ServiceForm.CostCentreId, ServiceForm.SRStatus, ServiceForm.Remarks, ServiceForm.CreatedBy, ServiceForm.CreatedDatetime, ServiceForm.SubmitedBy, ServiceForm.SubmitedDatetime, ServiceForm.ModifiedBy, ServiceForm.ModifiedDatetime, ServiceForm.CloseBy, ServiceForm.CloseDatetime, ServiceForm.CancelBy, ServiceForm.CancelDatetime, ServiceForm.RejectBy, ServiceForm.RejectDatetime, ServiceForm.ParentUniqueSRID, ServiceForm.IsUrgent, ServiceForm.AckDatetime, ServiceForm.AckBy, ServiceForm.EffectiveDate
					from ServiceForm
					" + where_clause, inputs);
        }

        public void insert
        (
            ref long? ID,
            string SRUniqueID,
            string DraftName,
            long? SRType,
            long? ToSiteID,
            long? ToCostCentreID,
            long? CostCentreId,
            long? SRStatus,
            string Remarks,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? SubmitedBy,
            DateTime? SubmitedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDatetime,
            long? CloseBy,
            DateTime? CloseDatetime,
            long? CancelBy,
            DateTime? CancelDatetime,
            long? RejectBy,
            DateTime? RejectDatetime,
            long? ParentUniqueSRID,
            int? IsUrgent,
            DateTime? AckDatetime,
            long? AckBy,
            DateTime? EffectiveDate
        )
        {

            m_db.Exec(@"
					insert into ServiceForm(
						SRUniqueID,
						DraftName,
						SRType,
						ToSiteID,
						ToCostCentreID,
						CostCentreId,
						SRStatus,
						Remarks,
						CreatedBy,
						CreatedDatetime,
						SubmitedBy,
						SubmitedDatetime,
						ModifiedBy,
						ModifiedDatetime,
						CloseBy,
						CloseDatetime,
						CancelBy,
						CancelDatetime,
						RejectBy,
						RejectDatetime,
						ParentUniqueSRID,
						IsUrgent,
						AckDatetime,
						AckBy,
						EffectiveDate
						)
					values(
						@SRUniqueID,
						@DraftName,
						@SRType,
						@ToSiteID,
						@ToCostCentreID,
						@CostCentreId,
						@SRStatus,
						@Remarks,
						@CreatedBy,
						@CreatedDatetime,
						@SubmitedBy,
						@SubmitedDatetime,
						@ModifiedBy,
						@ModifiedDatetime,
						@CloseBy,
						@CloseDatetime,
						@CancelBy,
						@CancelDatetime,
						@RejectBy,
						@RejectDatetime,
						@ParentUniqueSRID,
						@IsUrgent,
						@AckDatetime,
						@AckBy,
						@EffectiveDate
						)
					", SRUniqueID, DraftName, SRType, ToSiteID, ToCostCentreID, CostCentreId, SRStatus, Remarks, CreatedBy, CreatedDatetime, SubmitedBy, SubmitedDatetime, ModifiedBy, ModifiedDatetime, CloseBy, CloseDatetime, CancelBy, CancelDatetime, RejectBy, RejectDatetime, ParentUniqueSRID, IsUrgent, AckDatetime, AckBy, EffectiveDate);

            ID = m_db.SelectInt("select IDENT_CURRENT('ServiceForm')");
        }

        public void insert
        (
            string SRUniqueID,
            string DraftName,
            long? SRType,
            long? ToSiteID,
            long? ToCostCentreID,
            long? CostCentreId,
            long? SRStatus,
            string Remarks,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? SubmitedBy,
            DateTime? SubmitedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDatetime,
            long? CloseBy,
            DateTime? CloseDatetime,
            long? CancelBy,
            DateTime? CancelDatetime,
            long? RejectBy,
            DateTime? RejectDatetime,
            long? ParentUniqueSRID,
            int? IsUrgent,
            DateTime? AckDatetime,
            long? AckBy,
            DateTime? EffectiveDate
        )
        {
            m_db.Exec(@"
					insert into ServiceForm(
						SRUniqueID,
						DraftName,
						SRType,
						ToSiteID,
						ToCostCentreID,
						CostCentreId,
						SRStatus,
						Remarks,
						CreatedBy,
						CreatedDatetime,
						SubmitedBy,
						SubmitedDatetime,
						ModifiedBy,
						ModifiedDatetime,
						CloseBy,
						CloseDatetime,
						CancelBy,
						CancelDatetime,
						RejectBy,
						RejectDatetime,
						ParentUniqueSRID,
						IsUrgent,
						AckDatetime,
						AckBy,
						EffectiveDate
						)
					values(
						@SRUniqueID,
						@DraftName,
						@SRType,
						@ToSiteID,
						@ToCostCentreID,
						@CostCentreId,
						@SRStatus,
						@Remarks,
						@CreatedBy,
						@CreatedDatetime,
						@SubmitedBy,
						@SubmitedDatetime,
						@ModifiedBy,
						@ModifiedDatetime,
						@CloseBy,
						@CloseDatetime,
						@CancelBy,
						@CancelDatetime,
						@RejectBy,
						@RejectDatetime,
						@ParentUniqueSRID,
						@IsUrgent,
						@AckDatetime,
						@AckBy,
						@EffectiveDate
						)
					", SRUniqueID, DraftName, SRType, ToSiteID, ToCostCentreID, CostCentreId, SRStatus, Remarks, CreatedBy, CreatedDatetime, SubmitedBy, SubmitedDatetime, ModifiedBy, ModifiedDatetime, CloseBy, CloseDatetime, CancelBy, CancelDatetime, RejectBy, RejectDatetime, ParentUniqueSRID, IsUrgent, AckDatetime, AckBy, EffectiveDate);
        }

        public void update
        (
            long ID,
            string SRUniqueID,
            string DraftName,
            long? SRType,
            long? ToSiteID,
            long? ToCostCentreID,
            long? CostCentreId,
            long? SRStatus,
            string Remarks,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? SubmitedBy,
            DateTime? SubmitedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDatetime,
            long? CloseBy,
            DateTime? CloseDatetime,
            long? CancelBy,
            DateTime? CancelDatetime,
            long? RejectBy,
            DateTime? RejectDatetime,
            long? ParentUniqueSRID,
            int? IsUrgent,
            DateTime? AckDatetime,
            long? AckBy,
            DateTime? EffectiveDate
        )
        {
            int count = m_db.SelectCount(@"select * from ServiceForm where ID=@ID", ID);
            if (count == 0)
                throw new Exception("ServiceForm.update error. ID does not exists");

            m_db.Exec(@"
					update ServiceForm
					set
						SRUniqueID = @SRUniqueID,
						DraftName = @DraftName,
						SRType = @SRType,
						ToSiteID = @ToSiteID,
						ToCostCentreID = @ToCostCentreID,
						CostCentreId = @CostCentreId,
						SRStatus = @SRStatus,
						Remarks = @Remarks,
						CreatedBy = @CreatedBy,
						CreatedDatetime = @CreatedDatetime,
						SubmitedBy = @SubmitedBy,
						SubmitedDatetime = @SubmitedDatetime,
						ModifiedBy = @ModifiedBy,
						ModifiedDatetime = @ModifiedDatetime,
						CloseBy = @CloseBy,
						CloseDatetime = @CloseDatetime,
						CancelBy = @CancelBy,
						CancelDatetime = @CancelDatetime,
						RejectBy = @RejectBy,
						RejectDatetime = @RejectDatetime,
						ParentUniqueSRID = @ParentUniqueSRID,
						IsUrgent = @IsUrgent,
						AckDatetime = @AckDatetime,
						AckBy = @AckBy,
						EffectiveDate = @EffectiveDate
					where ID=@ID
					",
                SRUniqueID,
                DraftName,
                SRType,
                ToSiteID,
                ToCostCentreID,
                CostCentreId,
                SRStatus,
                Remarks,
                CreatedBy,
                CreatedDatetime,
                SubmitedBy,
                SubmitedDatetime,
                ModifiedBy,
                ModifiedDatetime,
                CloseBy,
                CloseDatetime,
                CancelBy,
                CancelDatetime,
                RejectBy,
                RejectDatetime,
                ParentUniqueSRID,
                IsUrgent,
                AckDatetime,
                AckBy,
                EffectiveDate,
                ID
            );
        }

        public void delete(long ID)
        {
            int count = m_db.SelectCount(@"select * from ServiceForm where ID=@ID", ID);
            if (count == 0)
                throw new Exception("ServiceForm.delete error. ID does not exists");

            m_db.Exec(@"delete from ServiceForm where ID=@ID", ID);
        }

    }

    #endregion

    #region SitesInOrganization
    //**********************************************************
    //  SitesInOrganization
    //**********************************************************
    CMD_SitesInOrganization m_SitesInOrganization = null;
    public CMD_SitesInOrganization SitesInOrganization
    {
        get
        {
            if (m_SitesInOrganization == null)
                m_SitesInOrganization = new CMD_SitesInOrganization(this);
            return m_SitesInOrganization;
        }
    }

    [Serializable]
    public class TBL_SitesInOrganization
    {
        public long ID { get; set; }
        public long OrgID { get; set; }
        public string SiteIDName { get; set; }
        public string SiteName { get; set; }
        public int SiteStatus { get; set; }
        public long CreatedBy { get; set; }
        public DateTime CreatedDatetime { get; set; }
        public long ModifiedBy { get; set; }
        public DateTime ModifiedDateTime { get; set; }

        public TBL_SitesInOrganization()
        {
            this.ID = 0;
            this.OrgID = 0;
            this.SiteIDName = "";
            this.SiteName = "";
            this.SiteStatus = 0;
            this.CreatedBy = 0;
            this.CreatedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
            this.ModifiedBy = 0;
            this.ModifiedDateTime = Convert.ToDateTime("1900-01-01 00:00:00");
        }

        public TBL_SitesInOrganization(long ID, long OrgID, string SiteIDName, string SiteName, int SiteStatus, long CreatedBy, DateTime CreatedDatetime, long ModifiedBy, DateTime ModifiedDateTime)
        {
            this.ID = ID;
            this.OrgID = OrgID;
            this.SiteIDName = SiteIDName;
            this.SiteName = SiteName;
            this.SiteStatus = SiteStatus;
            this.CreatedBy = CreatedBy;
            this.CreatedDatetime = CreatedDatetime;
            this.ModifiedBy = ModifiedBy;
            this.ModifiedDateTime = ModifiedDateTime;
        }

        public void CopyTo(ref TBL_SitesInOrganization to)
        {
            to.ID = this.ID;
            to.OrgID = this.OrgID;
            to.SiteIDName = this.SiteIDName;
            to.SiteName = this.SiteName;
            to.SiteStatus = this.SiteStatus;
            to.CreatedBy = this.CreatedBy;
            to.CreatedDatetime = this.CreatedDatetime;
            to.ModifiedBy = this.ModifiedBy;
            to.ModifiedDateTime = this.ModifiedDateTime;
        }

        public bool IsSame(TBL_SitesInOrganization x)
        {
            return (
                this.ID == x.ID &&
                this.OrgID == x.OrgID &&
                this.SiteIDName == x.SiteIDName &&
                this.SiteName == x.SiteName &&
                this.SiteStatus == x.SiteStatus &&
                this.CreatedBy == x.CreatedBy &&
                this.CreatedDatetime == x.CreatedDatetime &&
                this.ModifiedBy == x.ModifiedBy &&
                this.ModifiedDateTime == x.ModifiedDateTime
            );
        }

        public static TBL_SitesInOrganization ReadRow(DataRow row)
        {
            TBL_SitesInOrganization record = new TBL_SitesInOrganization();
            record.ID = get_long_value(row["ID"]);
            record.OrgID = get_long_value(row["OrgID"]);
            record.SiteIDName = get_string_value(row["SiteIDName"]);
            record.SiteName = get_string_value(row["SiteName"]);
            record.SiteStatus = get_int_value(row["SiteStatus"]);
            record.CreatedBy = get_long_value(row["CreatedBy"]);
            record.CreatedDatetime = get_DateTime_value(row["CreatedDatetime"]);
            record.ModifiedBy = get_long_value(row["ModifiedBy"]);
            record.ModifiedDateTime = get_DateTime_value(row["ModifiedDateTime"]);
            return record;
        }

        public static List<TBL_SitesInOrganization> ReadTable(DataTable dt)
        {
            List<TBL_SitesInOrganization> records = new List<TBL_SitesInOrganization>();
            foreach (DataRow row in dt.Rows)
                records.Add(ReadRow(row));
            return records;
        }
    }

    public class CMD_SitesInOrganization
    {
        private MyLib.DAL_MSSQL m_db = null;

        public CMD_SitesInOrganization(MyLib.DAL_MSSQL db)
        {
            m_db = db;
        }

        public DataTable select(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select ID, OrgID, SiteIDName, SiteName, SiteStatus, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime
					from SitesInOrganization
					" + where_clause, inputs);
        }

        public DataTable select()
        {
            return select("");
        }

        public DataTable selectPK(long ID)
        {
            return select(@"where ID=@ID"
                , ID);
        }

        public TBL_SitesInOrganization select2(string where_clause, params object[] inputs)
        {
            DataTable dt = select(where_clause, inputs);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_SitesInOrganization.ReadRow(dt.Rows[0]);
        }

        public TBL_SitesInOrganization selectPK2(long ID)
        {
            DataTable dt = selectPK(ID);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_SitesInOrganization.ReadRow(dt.Rows[0]);
        }

        public DataTable select_join(long ID)
        {
            return select_join("where SitesInOrganization.ID=@ID", ID);
        }

        public DataTable select_join()
        {
            return select_join("");
        }

        public DataTable select_join(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select SitesInOrganization.ID, SitesInOrganization.OrgID, SitesInOrganization.SiteIDName, SitesInOrganization.SiteName, SitesInOrganization.SiteStatus, SitesInOrganization.CreatedBy, SitesInOrganization.CreatedDatetime, SitesInOrganization.ModifiedBy, SitesInOrganization.ModifiedDateTime
					from SitesInOrganization
					" + where_clause, inputs);
        }

        public void insert
        (
            ref long? ID,
            long? OrgID,
            string SiteIDName,
            string SiteName,
            int? SiteStatus,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDateTime
        )
        {

            m_db.Exec(@"
					insert into SitesInOrganization(
						OrgID,
						SiteIDName,
						SiteName,
						SiteStatus,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDateTime
						)
					values(
						@OrgID,
						@SiteIDName,
						@SiteName,
						@SiteStatus,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDateTime
						)
					", OrgID, SiteIDName, SiteName, SiteStatus, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime);

            ID = m_db.SelectInt("select IDENT_CURRENT('SitesInOrganization')");
        }

        public void insert
        (
            long? OrgID,
            string SiteIDName,
            string SiteName,
            int? SiteStatus,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDateTime
        )
        {
            m_db.Exec(@"
					insert into SitesInOrganization(
						OrgID,
						SiteIDName,
						SiteName,
						SiteStatus,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDateTime
						)
					values(
						@OrgID,
						@SiteIDName,
						@SiteName,
						@SiteStatus,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDateTime
						)
					", OrgID, SiteIDName, SiteName, SiteStatus, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime);
        }

        public void update
        (
            long ID,
            long? OrgID,
            string SiteIDName,
            string SiteName,
            int? SiteStatus,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDateTime
        )
        {
            int count = m_db.SelectCount(@"select * from SitesInOrganization where ID=@ID", ID);
            if (count == 0)
                throw new Exception("SitesInOrganization.update error. ID does not exists");

            m_db.Exec(@"
					update SitesInOrganization
					set
						OrgID = @OrgID,
						SiteIDName = @SiteIDName,
						SiteName = @SiteName,
						SiteStatus = @SiteStatus,
						CreatedBy = @CreatedBy,
						CreatedDatetime = @CreatedDatetime,
						ModifiedBy = @ModifiedBy,
						ModifiedDateTime = @ModifiedDateTime
					where ID=@ID
					",
                OrgID,
                SiteIDName,
                SiteName,
                SiteStatus,
                CreatedBy,
                CreatedDatetime,
                ModifiedBy,
                ModifiedDateTime,
                ID
            );
        }

        public void delete(long ID)
        {
            int count = m_db.SelectCount(@"select * from SitesInOrganization where ID=@ID", ID);
            if (count == 0)
                throw new Exception("SitesInOrganization.delete error. ID does not exists");

            m_db.Exec(@"delete from SitesInOrganization where ID=@ID", ID);
        }

    }

    #endregion

    #region Subscriber
    //**********************************************************
    //  Subscriber
    //**********************************************************
    CMD_Subscriber m_Subscriber = null;
    public CMD_Subscriber Subscriber
    {
        get
        {
            if (m_Subscriber == null)
                m_Subscriber = new CMD_Subscriber(this);
            return m_Subscriber;
        }
    }

    [Serializable]
    public class TBL_Subscriber
    {
        public long ID { get; set; }
        public long ServiceFormID { get; set; }
        public long MasterProfileID { get; set; }
        public DateTime EffectiveDate { get; set; }
        public DateTime TerminatedDate { get; set; }
        public long TerminatedBy { get; set; }
        public long CreatedBy { get; set; }
        public DateTime CreatedDatetime { get; set; }
        public long ModifiedBy { get; set; }
        public DateTime ModifiedDateTime { get; set; }
        public long CostCentreID { get; set; }
        public string Email { get; set; }
        public string Username { get; set; }
        public string ServiceType { get; set; }
        public string AssetID { get; set; }
        public string Hostname { get; set; }
        public string OS { get; set; }
        public int Status { get; set; }

        public TBL_Subscriber()
        {
            this.ID = 0;
            this.ServiceFormID = 0;
            this.MasterProfileID = 0;
            this.EffectiveDate = Convert.ToDateTime("1900-01-01 00:00:00");
            this.TerminatedDate = Convert.ToDateTime("1900-01-01 00:00:00");
            this.TerminatedBy = 0;
            this.CreatedBy = 0;
            this.CreatedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
            this.ModifiedBy = 0;
            this.ModifiedDateTime = Convert.ToDateTime("1900-01-01 00:00:00");
            this.CostCentreID = 0;
            this.Email = "";
            this.Username = "";
            this.ServiceType = "";
            this.AssetID = "";
            this.Hostname = "";
            this.OS = "";
            this.Status = 0;
        }

        public TBL_Subscriber(long ID, long ServiceFormID, long MasterProfileID, DateTime EffectiveDate, DateTime TerminatedDate, long TerminatedBy, long CreatedBy, DateTime CreatedDatetime, long ModifiedBy, DateTime ModifiedDateTime, long CostCentreID, string Email, string Username, string ServiceType, string AssetID, string Hostname, string OS, int Status)
        {
            this.ID = ID;
            this.ServiceFormID = ServiceFormID;
            this.MasterProfileID = MasterProfileID;
            this.EffectiveDate = EffectiveDate;
            this.TerminatedDate = TerminatedDate;
            this.TerminatedBy = TerminatedBy;
            this.CreatedBy = CreatedBy;
            this.CreatedDatetime = CreatedDatetime;
            this.ModifiedBy = ModifiedBy;
            this.ModifiedDateTime = ModifiedDateTime;
            this.CostCentreID = CostCentreID;
            this.Email = Email;
            this.Username = Username;
            this.ServiceType = ServiceType;
            this.AssetID = AssetID;
            this.Hostname = Hostname;
            this.OS = OS;
            this.Status = Status;
        }

        public void CopyTo(ref TBL_Subscriber to)
        {
            to.ID = this.ID;
            to.ServiceFormID = this.ServiceFormID;
            to.MasterProfileID = this.MasterProfileID;
            to.EffectiveDate = this.EffectiveDate;
            to.TerminatedDate = this.TerminatedDate;
            to.TerminatedBy = this.TerminatedBy;
            to.CreatedBy = this.CreatedBy;
            to.CreatedDatetime = this.CreatedDatetime;
            to.ModifiedBy = this.ModifiedBy;
            to.ModifiedDateTime = this.ModifiedDateTime;
            to.CostCentreID = this.CostCentreID;
            to.Email = this.Email;
            to.Username = this.Username;
            to.ServiceType = this.ServiceType;
            to.AssetID = this.AssetID;
            to.Hostname = this.Hostname;
            to.OS = this.OS;
            to.Status = this.Status;
        }

        public bool IsSame(TBL_Subscriber x)
        {
            return (
                this.ID == x.ID &&
                this.ServiceFormID == x.ServiceFormID &&
                this.MasterProfileID == x.MasterProfileID &&
                this.EffectiveDate == x.EffectiveDate &&
                this.TerminatedDate == x.TerminatedDate &&
                this.TerminatedBy == x.TerminatedBy &&
                this.CreatedBy == x.CreatedBy &&
                this.CreatedDatetime == x.CreatedDatetime &&
                this.ModifiedBy == x.ModifiedBy &&
                this.ModifiedDateTime == x.ModifiedDateTime &&
                this.CostCentreID == x.CostCentreID &&
                this.Email == x.Email &&
                this.Username == x.Username &&
                this.ServiceType == x.ServiceType &&
                this.AssetID == x.AssetID &&
                this.Hostname == x.Hostname &&
                this.OS == x.OS &&
                this.Status == x.Status
            );
        }

        public static TBL_Subscriber ReadRow(DataRow row)
        {
            TBL_Subscriber record = new TBL_Subscriber();
            record.ID = get_long_value(row["ID"]);
            record.ServiceFormID = get_long_value(row["ServiceFormID"]);
            record.MasterProfileID = get_long_value(row["MasterProfileID"]);
            record.EffectiveDate = get_DateTime_value(row["EffectiveDate"]);
            record.TerminatedDate = get_DateTime_value(row["TerminatedDate"]);
            record.TerminatedBy = get_long_value(row["TerminatedBy"]);
            record.CreatedBy = get_long_value(row["CreatedBy"]);
            record.CreatedDatetime = get_DateTime_value(row["CreatedDatetime"]);
            record.ModifiedBy = get_long_value(row["ModifiedBy"]);
            record.ModifiedDateTime = get_DateTime_value(row["ModifiedDateTime"]);
            record.CostCentreID = get_long_value(row["CostCentreID"]);
            record.Email = get_string_value(row["Email"]);
            record.Username = get_string_value(row["Username"]);
            record.ServiceType = get_string_value(row["ServiceType"]);
            record.AssetID = get_string_value(row["AssetID"]);
            record.Hostname = get_string_value(row["Hostname"]);
            record.OS = get_string_value(row["OS"]);
            record.Status = get_int_value(row["Status"]);
            return record;
        }

        public static List<TBL_Subscriber> ReadTable(DataTable dt)
        {
            List<TBL_Subscriber> records = new List<TBL_Subscriber>();
            foreach (DataRow row in dt.Rows)
                records.Add(ReadRow(row));
            return records;
        }
    }

    public class CMD_Subscriber
    {
        private MyLib.DAL_MSSQL m_db = null;

        public CMD_Subscriber(MyLib.DAL_MSSQL db)
        {
            m_db = db;
        }

        public DataTable select(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select ID, ServiceFormID, MasterProfileID, EffectiveDate, TerminatedDate, TerminatedBy, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime, CostCentreID, Email, Username, ServiceType, AssetID, Hostname, OS, Status
					from Subscriber
					" + where_clause, inputs);
        }

        public DataTable select()
        {
            return select("");
        }

        public DataTable selectPK(long ID)
        {
            return select(@"where ID=@ID"
                , ID);
        }

        public TBL_Subscriber select2(string where_clause, params object[] inputs)
        {
            DataTable dt = select(where_clause, inputs);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_Subscriber.ReadRow(dt.Rows[0]);
        }

        public TBL_Subscriber selectPK2(long ID)
        {
            DataTable dt = selectPK(ID);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_Subscriber.ReadRow(dt.Rows[0]);
        }

        public DataTable select_join(long ID)
        {
            return select_join("where Subscriber.ID=@ID", ID);
        }

        public DataTable select_join()
        {
            return select_join("");
        }

        public DataTable select_join(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select Subscriber.ID, Subscriber.ServiceFormID, Subscriber.MasterProfileID, Subscriber.EffectiveDate, Subscriber.TerminatedDate, Subscriber.TerminatedBy, Subscriber.CreatedBy, Subscriber.CreatedDatetime, Subscriber.ModifiedBy, Subscriber.ModifiedDateTime, Subscriber.CostCentreID, Subscriber.Email, Subscriber.Username, Subscriber.ServiceType, Subscriber.AssetID, Subscriber.Hostname, Subscriber.OS, Subscriber.Status
					from Subscriber
					" + where_clause, inputs);
        }

        public void insert
        (
            ref long? ID,
            long? ServiceFormID,
            long? MasterProfileID,
            DateTime? EffectiveDate,
            DateTime? TerminatedDate,
            long? TerminatedBy,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDateTime,
            long? CostCentreID,
            string Email,
            string Username,
            string ServiceType,
            string AssetID,
            string Hostname,
            string OS,
            int? Status
        )
        {

            m_db.Exec(@"
					insert into Subscriber(
						ServiceFormID,
						MasterProfileID,
						EffectiveDate,
						TerminatedDate,
						TerminatedBy,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDateTime,
						CostCentreID,
						Email,
						Username,
						ServiceType,
						AssetID,
						Hostname,
						OS,
						Status
						)
					values(
						@ServiceFormID,
						@MasterProfileID,
						@EffectiveDate,
						@TerminatedDate,
						@TerminatedBy,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDateTime,
						@CostCentreID,
						@Email,
						@Username,
						@ServiceType,
						@AssetID,
						@Hostname,
						@OS,
						@Status
						)
					", ServiceFormID, MasterProfileID, EffectiveDate, TerminatedDate, TerminatedBy, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime, CostCentreID, Email, Username, ServiceType, AssetID, Hostname, OS, Status);

            ID = m_db.SelectInt("select IDENT_CURRENT('Subscriber')");
        }

        public void insert
        (
            long? ServiceFormID,
            long? MasterProfileID,
            DateTime? EffectiveDate,
            DateTime? TerminatedDate,
            long? TerminatedBy,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDateTime,
            long? CostCentreID,
            string Email,
            string Username,
            string ServiceType,
            string AssetID,
            string Hostname,
            string OS,
            int? Status
        )
        {
            m_db.Exec(@"
					insert into Subscriber(
						ServiceFormID,
						MasterProfileID,
						EffectiveDate,
						TerminatedDate,
						TerminatedBy,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDateTime,
						CostCentreID,
						Email,
						Username,
						ServiceType,
						AssetID,
						Hostname,
						OS,
						Status
						)
					values(
						@ServiceFormID,
						@MasterProfileID,
						@EffectiveDate,
						@TerminatedDate,
						@TerminatedBy,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDateTime,
						@CostCentreID,
						@Email,
						@Username,
						@ServiceType,
						@AssetID,
						@Hostname,
						@OS,
						@Status
						)
					", ServiceFormID, MasterProfileID, EffectiveDate, TerminatedDate, TerminatedBy, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime, CostCentreID, Email, Username, ServiceType, AssetID, Hostname, OS, Status);
        }

        public void update
        (
            long ID,
            long? ServiceFormID,
            long? MasterProfileID,
            DateTime? EffectiveDate,
            DateTime? TerminatedDate,
            long? TerminatedBy,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDateTime,
            long? CostCentreID,
            string Email,
            string Username,
            string ServiceType,
            string AssetID,
            string Hostname,
            string OS,
            int? Status
        )
        {
            int count = m_db.SelectCount(@"select * from Subscriber where ID=@ID", ID);
            if (count == 0)
                throw new Exception("Subscriber.update error. ID does not exists");

            m_db.Exec(@"
					update Subscriber
					set
						ServiceFormID = @ServiceFormID,
						MasterProfileID = @MasterProfileID,
						EffectiveDate = @EffectiveDate,
						TerminatedDate = @TerminatedDate,
						TerminatedBy = @TerminatedBy,
						CreatedBy = @CreatedBy,
						CreatedDatetime = @CreatedDatetime,
						ModifiedBy = @ModifiedBy,
						ModifiedDateTime = @ModifiedDateTime,
						CostCentreID = @CostCentreID,
						Email = @Email,
						Username = @Username,
						ServiceType = @ServiceType,
						AssetID = @AssetID,
						Hostname = @Hostname,
						OS = @OS,
						Status = @Status
					where ID=@ID
					",
                ServiceFormID,
                MasterProfileID,
                EffectiveDate,
                TerminatedDate,
                TerminatedBy,
                CreatedBy,
                CreatedDatetime,
                ModifiedBy,
                ModifiedDateTime,
                CostCentreID,
                Email,
                Username,
                ServiceType,
                AssetID,
                Hostname,
                OS,
                Status,
                ID
            );
        }

        public void delete(long ID)
        {
            int count = m_db.SelectCount(@"select * from Subscriber where ID=@ID", ID);
            if (count == 0)
                throw new Exception("Subscriber.delete error. ID does not exists");

            m_db.Exec(@"delete from Subscriber where ID=@ID", ID);
        }

    }

    #endregion

    #region SubscriberCC
    //**********************************************************
    //  SubscriberCC
    //**********************************************************
    CMD_SubscriberCC m_SubscriberCC = null;
    public CMD_SubscriberCC SubscriberCC
    {
        get
        {
            if (m_SubscriberCC == null)
                m_SubscriberCC = new CMD_SubscriberCC(this);
            return m_SubscriberCC;
        }
    }

    [Serializable]
    public class TBL_SubscriberCC
    {
        public long ID { get; set; }
        public long ServiceFormID { get; set; }
        public long MasterProfileID { get; set; }
        public DateTime EffectiveDate { get; set; }
        public DateTime TerminatedDate { get; set; }
        public long TerminatedBy { get; set; }
        public long CreatedBy { get; set; }
        public DateTime CreatedDatetime { get; set; }
        public long ModifiedBy { get; set; }
        public DateTime ModifiedDateTime { get; set; }
        public long CostCentreID { get; set; }
        public string Email { get; set; }
        public string Username { get; set; }
        public string ServiceType { get; set; }
        public string AssetID { get; set; }
        public string Hostname { get; set; }
        public string OS { get; set; }
        public int Status { get; set; }

        public TBL_SubscriberCC()
        {
            this.ID = 0;
            this.ServiceFormID = 0;
            this.MasterProfileID = 0;
            this.EffectiveDate = Convert.ToDateTime("1900-01-01 00:00:00");
            this.TerminatedDate = Convert.ToDateTime("1900-01-01 00:00:00");
            this.TerminatedBy = 0;
            this.CreatedBy = 0;
            this.CreatedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
            this.ModifiedBy = 0;
            this.ModifiedDateTime = Convert.ToDateTime("1900-01-01 00:00:00");
            this.CostCentreID = 0;
            this.Email = "";
            this.Username = "";
            this.ServiceType = "";
            this.AssetID = "";
            this.Hostname = "";
            this.OS = "";
            this.Status = 0;
        }

        public TBL_SubscriberCC(long ID, long ServiceFormID, long MasterProfileID, DateTime EffectiveDate, DateTime TerminatedDate, long TerminatedBy, long CreatedBy, DateTime CreatedDatetime, long ModifiedBy, DateTime ModifiedDateTime, long CostCentreID, string Email, string Username, string ServiceType, string AssetID, string Hostname, string OS, int Status)
        {
            this.ID = ID;
            this.ServiceFormID = ServiceFormID;
            this.MasterProfileID = MasterProfileID;
            this.EffectiveDate = EffectiveDate;
            this.TerminatedDate = TerminatedDate;
            this.TerminatedBy = TerminatedBy;
            this.CreatedBy = CreatedBy;
            this.CreatedDatetime = CreatedDatetime;
            this.ModifiedBy = ModifiedBy;
            this.ModifiedDateTime = ModifiedDateTime;
            this.CostCentreID = CostCentreID;
            this.Email = Email;
            this.Username = Username;
            this.ServiceType = ServiceType;
            this.AssetID = AssetID;
            this.Hostname = Hostname;
            this.OS = OS;
            this.Status = Status;
        }

        public void CopyTo(ref TBL_SubscriberCC to)
        {
            to.ID = this.ID;
            to.ServiceFormID = this.ServiceFormID;
            to.MasterProfileID = this.MasterProfileID;
            to.EffectiveDate = this.EffectiveDate;
            to.TerminatedDate = this.TerminatedDate;
            to.TerminatedBy = this.TerminatedBy;
            to.CreatedBy = this.CreatedBy;
            to.CreatedDatetime = this.CreatedDatetime;
            to.ModifiedBy = this.ModifiedBy;
            to.ModifiedDateTime = this.ModifiedDateTime;
            to.CostCentreID = this.CostCentreID;
            to.Email = this.Email;
            to.Username = this.Username;
            to.ServiceType = this.ServiceType;
            to.AssetID = this.AssetID;
            to.Hostname = this.Hostname;
            to.OS = this.OS;
            to.Status = this.Status;
        }

        public bool IsSame(TBL_SubscriberCC x)
        {
            return (
                this.ID == x.ID &&
                this.ServiceFormID == x.ServiceFormID &&
                this.MasterProfileID == x.MasterProfileID &&
                this.EffectiveDate == x.EffectiveDate &&
                this.TerminatedDate == x.TerminatedDate &&
                this.TerminatedBy == x.TerminatedBy &&
                this.CreatedBy == x.CreatedBy &&
                this.CreatedDatetime == x.CreatedDatetime &&
                this.ModifiedBy == x.ModifiedBy &&
                this.ModifiedDateTime == x.ModifiedDateTime &&
                this.CostCentreID == x.CostCentreID &&
                this.Email == x.Email &&
                this.Username == x.Username &&
                this.ServiceType == x.ServiceType &&
                this.AssetID == x.AssetID &&
                this.Hostname == x.Hostname &&
                this.OS == x.OS &&
                this.Status == x.Status
            );
        }

        public static TBL_SubscriberCC ReadRow(DataRow row)
        {
            TBL_SubscriberCC record = new TBL_SubscriberCC();
            record.ID = get_long_value(row["ID"]);
            record.ServiceFormID = get_long_value(row["ServiceFormID"]);
            record.MasterProfileID = get_long_value(row["MasterProfileID"]);
            record.EffectiveDate = get_DateTime_value(row["EffectiveDate"]);
            record.TerminatedDate = get_DateTime_value(row["TerminatedDate"]);
            record.TerminatedBy = get_long_value(row["TerminatedBy"]);
            record.CreatedBy = get_long_value(row["CreatedBy"]);
            record.CreatedDatetime = get_DateTime_value(row["CreatedDatetime"]);
            record.ModifiedBy = get_long_value(row["ModifiedBy"]);
            record.ModifiedDateTime = get_DateTime_value(row["ModifiedDateTime"]);
            record.CostCentreID = get_long_value(row["CostCentreID"]);
            record.Email = get_string_value(row["Email"]);
            record.Username = get_string_value(row["Username"]);
            record.ServiceType = get_string_value(row["ServiceType"]);
            record.AssetID = get_string_value(row["AssetID"]);
            record.Hostname = get_string_value(row["Hostname"]);
            record.OS = get_string_value(row["OS"]);
            record.Status = get_int_value(row["Status"]);
            return record;
        }

        public static List<TBL_SubscriberCC> ReadTable(DataTable dt)
        {
            List<TBL_SubscriberCC> records = new List<TBL_SubscriberCC>();
            foreach (DataRow row in dt.Rows)
                records.Add(ReadRow(row));
            return records;
        }
    }

    public class CMD_SubscriberCC
    {
        private MyLib.DAL_MSSQL m_db = null;

        public CMD_SubscriberCC(MyLib.DAL_MSSQL db)
        {
            m_db = db;
        }

        public DataTable select(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select ID, ServiceFormID, MasterProfileID, EffectiveDate, TerminatedDate, TerminatedBy, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime, CostCentreID, Email, Username, ServiceType, AssetID, Hostname, OS, Status
					from SubscriberCC
					" + where_clause, inputs);
        }

        public DataTable select()
        {
            return select("");
        }

        public DataTable selectPK(long ID)
        {
            return select(@"where ID=@ID"
                , ID);
        }

        public TBL_SubscriberCC select2(string where_clause, params object[] inputs)
        {
            DataTable dt = select(where_clause, inputs);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_SubscriberCC.ReadRow(dt.Rows[0]);
        }

        public TBL_SubscriberCC selectPK2(long ID)
        {
            DataTable dt = selectPK(ID);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_SubscriberCC.ReadRow(dt.Rows[0]);
        }

        public DataTable select_join(long ID)
        {
            return select_join("where SubscriberCC.ID=@ID", ID);
        }

        public DataTable select_join()
        {
            return select_join("");
        }

        public DataTable select_join(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select SubscriberCC.ID, SubscriberCC.ServiceFormID, SubscriberCC.MasterProfileID, SubscriberCC.EffectiveDate, SubscriberCC.TerminatedDate, SubscriberCC.TerminatedBy, SubscriberCC.CreatedBy, SubscriberCC.CreatedDatetime, SubscriberCC.ModifiedBy, SubscriberCC.ModifiedDateTime, SubscriberCC.CostCentreID, SubscriberCC.Email, SubscriberCC.Username, SubscriberCC.ServiceType, SubscriberCC.AssetID, SubscriberCC.Hostname, SubscriberCC.OS, SubscriberCC.Status
					from SubscriberCC
					" + where_clause, inputs);
        }

        public void insert
        (
            ref long? ID,
            long? ServiceFormID,
            long? MasterProfileID,
            DateTime? EffectiveDate,
            DateTime? TerminatedDate,
            long? TerminatedBy,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDateTime,
            long? CostCentreID,
            string Email,
            string Username,
            string ServiceType,
            string AssetID,
            string Hostname,
            string OS,
            int? Status
        )
        {

            m_db.Exec(@"
					insert into SubscriberCC(
						ServiceFormID,
						MasterProfileID,
						EffectiveDate,
						TerminatedDate,
						TerminatedBy,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDateTime,
						CostCentreID,
						Email,
						Username,
						ServiceType,
						AssetID,
						Hostname,
						OS,
						Status
						)
					values(
						@ServiceFormID,
						@MasterProfileID,
						@EffectiveDate,
						@TerminatedDate,
						@TerminatedBy,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDateTime,
						@CostCentreID,
						@Email,
						@Username,
						@ServiceType,
						@AssetID,
						@Hostname,
						@OS,
						@Status
						)
					", ServiceFormID, MasterProfileID, EffectiveDate, TerminatedDate, TerminatedBy, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime, CostCentreID, Email, Username, ServiceType, AssetID, Hostname, OS, Status);

            ID = m_db.SelectInt("select IDENT_CURRENT('SubscriberCC')");
        }

        public void insert
        (
            long? ServiceFormID,
            long? MasterProfileID,
            DateTime? EffectiveDate,
            DateTime? TerminatedDate,
            long? TerminatedBy,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDateTime,
            long? CostCentreID,
            string Email,
            string Username,
            string ServiceType,
            string AssetID,
            string Hostname,
            string OS,
            int? Status
        )
        {
            m_db.Exec(@"
					insert into SubscriberCC(
						ServiceFormID,
						MasterProfileID,
						EffectiveDate,
						TerminatedDate,
						TerminatedBy,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDateTime,
						CostCentreID,
						Email,
						Username,
						ServiceType,
						AssetID,
						Hostname,
						OS,
						Status
						)
					values(
						@ServiceFormID,
						@MasterProfileID,
						@EffectiveDate,
						@TerminatedDate,
						@TerminatedBy,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDateTime,
						@CostCentreID,
						@Email,
						@Username,
						@ServiceType,
						@AssetID,
						@Hostname,
						@OS,
						@Status
						)
					", ServiceFormID, MasterProfileID, EffectiveDate, TerminatedDate, TerminatedBy, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime, CostCentreID, Email, Username, ServiceType, AssetID, Hostname, OS, Status);
        }

        public void update
        (
            long ID,
            long? ServiceFormID,
            long? MasterProfileID,
            DateTime? EffectiveDate,
            DateTime? TerminatedDate,
            long? TerminatedBy,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDateTime,
            long? CostCentreID,
            string Email,
            string Username,
            string ServiceType,
            string AssetID,
            string Hostname,
            string OS,
            int? Status
        )
        {
            int count = m_db.SelectCount(@"select * from SubscriberCC where ID=@ID", ID);
            if (count == 0)
                throw new Exception("SubscriberCC.update error. ID does not exists");

            m_db.Exec(@"
					update SubscriberCC
					set
						ServiceFormID = @ServiceFormID,
						MasterProfileID = @MasterProfileID,
						EffectiveDate = @EffectiveDate,
						TerminatedDate = @TerminatedDate,
						TerminatedBy = @TerminatedBy,
						CreatedBy = @CreatedBy,
						CreatedDatetime = @CreatedDatetime,
						ModifiedBy = @ModifiedBy,
						ModifiedDateTime = @ModifiedDateTime,
						CostCentreID = @CostCentreID,
						Email = @Email,
						Username = @Username,
						ServiceType = @ServiceType,
						AssetID = @AssetID,
						Hostname = @Hostname,
						OS = @OS,
						Status = @Status
					where ID=@ID
					",
                ServiceFormID,
                MasterProfileID,
                EffectiveDate,
                TerminatedDate,
                TerminatedBy,
                CreatedBy,
                CreatedDatetime,
                ModifiedBy,
                ModifiedDateTime,
                CostCentreID,
                Email,
                Username,
                ServiceType,
                AssetID,
                Hostname,
                OS,
                Status,
                ID
            );
        }

        public void delete(long ID)
        {
            int count = m_db.SelectCount(@"select * from SubscriberCC where ID=@ID", ID);
            if (count == 0)
                throw new Exception("SubscriberCC.delete error. ID does not exists");

            m_db.Exec(@"delete from SubscriberCC where ID=@ID", ID);
        }

    }

    #endregion

    #region UserProfile
    //**********************************************************
    //  UserProfile
    //**********************************************************
    CMD_UserProfile m_UserProfile = null;
    public CMD_UserProfile UserProfile
    {
        get
        {
            if (m_UserProfile == null)
                m_UserProfile = new CMD_UserProfile(this);
            return m_UserProfile;
        }
    }

    [Serializable]
    public class TBL_UserProfile
    {
        public long UserId { get; set; }
        public string LoginId { get; set; }
        public string LoginPassword { get; set; }
        public string NRIC { get; set; }
        public string Name0 { get; set; }
        public string Address01 { get; set; }
        public string Address02 { get; set; }
        public string PostCode { get; set; }
        public string PrimaryPhone { get; set; }
        public string SecondaryPhone { get; set; }
        public string FaxNumber { get; set; }
        public string Email { get; set; }
        public long UserTypeId { get; set; }
        public long OrgID { get; set; }
        public long SiteID { get; set; }
        public long CostCentreID { get; set; }
        public int UserStatus { get; set; }
        public long CreatedBy { get; set; }
        public DateTime CreatedDatetime { get; set; }
        public long ModifiedBy { get; set; }
        public DateTime ModifiedDateTime { get; set; }
        public DateTime LastLogin { get; set; }

        public TBL_UserProfile()
        {
            this.UserId = 0;
            this.LoginId = "";
            this.LoginPassword = "";
            this.NRIC = "";
            this.Name0 = "";
            this.Address01 = "";
            this.Address02 = "";
            this.PostCode = "";
            this.PrimaryPhone = "";
            this.SecondaryPhone = "";
            this.FaxNumber = "";
            this.Email = "";
            this.UserTypeId = 0;
            this.OrgID = 0;
            this.SiteID = 0;
            this.CostCentreID = 0;
            this.UserStatus = 0;
            this.CreatedBy = 0;
            this.CreatedDatetime = Convert.ToDateTime("1900-01-01 00:00:00");
            this.ModifiedBy = 0;
            this.ModifiedDateTime = Convert.ToDateTime("1900-01-01 00:00:00");
            this.LastLogin = Convert.ToDateTime("1900-01-01 00:00:00");
        }

        public TBL_UserProfile(long UserId, string LoginId, string LoginPassword, string NRIC, string Name0, string Address01, string Address02, string PostCode, string PrimaryPhone, string SecondaryPhone, string FaxNumber, string Email, long UserTypeId, long OrgID, long SiteID, long CostCentreID, int UserStatus, long CreatedBy, DateTime CreatedDatetime, long ModifiedBy, DateTime ModifiedDateTime, DateTime LastLogin)
        {
            this.UserId = UserId;
            this.LoginId = LoginId;
            this.LoginPassword = LoginPassword;
            this.NRIC = NRIC;
            this.Name0 = Name0;
            this.Address01 = Address01;
            this.Address02 = Address02;
            this.PostCode = PostCode;
            this.PrimaryPhone = PrimaryPhone;
            this.SecondaryPhone = SecondaryPhone;
            this.FaxNumber = FaxNumber;
            this.Email = Email;
            this.UserTypeId = UserTypeId;
            this.OrgID = OrgID;
            this.SiteID = SiteID;
            this.CostCentreID = CostCentreID;
            this.UserStatus = UserStatus;
            this.CreatedBy = CreatedBy;
            this.CreatedDatetime = CreatedDatetime;
            this.ModifiedBy = ModifiedBy;
            this.ModifiedDateTime = ModifiedDateTime;
            this.LastLogin = LastLogin;
        }

        public void CopyTo(ref TBL_UserProfile to)
        {
            to.UserId = this.UserId;
            to.LoginId = this.LoginId;
            to.LoginPassword = this.LoginPassword;
            to.NRIC = this.NRIC;
            to.Name0 = this.Name0;
            to.Address01 = this.Address01;
            to.Address02 = this.Address02;
            to.PostCode = this.PostCode;
            to.PrimaryPhone = this.PrimaryPhone;
            to.SecondaryPhone = this.SecondaryPhone;
            to.FaxNumber = this.FaxNumber;
            to.Email = this.Email;
            to.UserTypeId = this.UserTypeId;
            to.OrgID = this.OrgID;
            to.SiteID = this.SiteID;
            to.CostCentreID = this.CostCentreID;
            to.UserStatus = this.UserStatus;
            to.CreatedBy = this.CreatedBy;
            to.CreatedDatetime = this.CreatedDatetime;
            to.ModifiedBy = this.ModifiedBy;
            to.ModifiedDateTime = this.ModifiedDateTime;
            to.LastLogin = this.LastLogin;
        }

        public bool IsSame(TBL_UserProfile x)
        {
            return (
                this.UserId == x.UserId &&
                this.LoginId == x.LoginId &&
                this.LoginPassword == x.LoginPassword &&
                this.NRIC == x.NRIC &&
                this.Name0 == x.Name0 &&
                this.Address01 == x.Address01 &&
                this.Address02 == x.Address02 &&
                this.PostCode == x.PostCode &&
                this.PrimaryPhone == x.PrimaryPhone &&
                this.SecondaryPhone == x.SecondaryPhone &&
                this.FaxNumber == x.FaxNumber &&
                this.Email == x.Email &&
                this.UserTypeId == x.UserTypeId &&
                this.OrgID == x.OrgID &&
                this.SiteID == x.SiteID &&
                this.CostCentreID == x.CostCentreID &&
                this.UserStatus == x.UserStatus &&
                this.CreatedBy == x.CreatedBy &&
                this.CreatedDatetime == x.CreatedDatetime &&
                this.ModifiedBy == x.ModifiedBy &&
                this.ModifiedDateTime == x.ModifiedDateTime &&
                this.LastLogin == x.LastLogin
            );
        }

        public static TBL_UserProfile ReadRow(DataRow row)
        {
            TBL_UserProfile record = new TBL_UserProfile();
            record.UserId = get_long_value(row["UserId"]);
            record.LoginId = get_string_value(row["LoginId"]);
            record.LoginPassword = get_string_value(row["LoginPassword"]);
            record.NRIC = get_string_value(row["NRIC"]);
            record.Name0 = get_string_value(row["Name0"]);
            record.Address01 = get_string_value(row["Address01"]);
            record.Address02 = get_string_value(row["Address02"]);
            record.PostCode = get_string_value(row["PostCode"]);
            record.PrimaryPhone = get_string_value(row["PrimaryPhone"]);
            record.SecondaryPhone = get_string_value(row["SecondaryPhone"]);
            record.FaxNumber = get_string_value(row["FaxNumber"]);
            record.Email = get_string_value(row["Email"]);
            record.UserTypeId = get_long_value(row["UserTypeId"]);
            record.OrgID = get_long_value(row["OrgID"]);
            record.SiteID = get_long_value(row["SiteID"]);
            record.CostCentreID = get_long_value(row["CostCentreID"]);
            record.UserStatus = get_int_value(row["UserStatus"]);
            record.CreatedBy = get_long_value(row["CreatedBy"]);
            record.CreatedDatetime = get_DateTime_value(row["CreatedDatetime"]);
            record.ModifiedBy = get_long_value(row["ModifiedBy"]);
            record.ModifiedDateTime = get_DateTime_value(row["ModifiedDateTime"]);
            record.LastLogin = get_DateTime_value(row["LastLogin"]);
            return record;
        }

        public static List<TBL_UserProfile> ReadTable(DataTable dt)
        {
            List<TBL_UserProfile> records = new List<TBL_UserProfile>();
            foreach (DataRow row in dt.Rows)
                records.Add(ReadRow(row));
            return records;
        }
    }

    public class CMD_UserProfile
    {
        private MyLib.DAL_MSSQL m_db = null;

        public CMD_UserProfile(MyLib.DAL_MSSQL db)
        {
            m_db = db;
        }

        public DataTable select(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select UserId, LoginId, LoginPassword, NRIC, Name0, Address01, Address02, PostCode, PrimaryPhone, SecondaryPhone, FaxNumber, Email, UserTypeId, OrgID, SiteID, CostCentreID, UserStatus, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime, LastLogin
					from UserProfile
					" + where_clause, inputs);
        }

        public DataTable select()
        {
            return select("");
        }

        public DataTable selectPK(long UserId)
        {
            return select(@"where UserId=@UserId"
                , UserId);
        }

        public TBL_UserProfile select2(string where_clause, params object[] inputs)
        {
            DataTable dt = select(where_clause, inputs);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_UserProfile.ReadRow(dt.Rows[0]);
        }

        public TBL_UserProfile selectPK2(long UserId)
        {
            DataTable dt = selectPK(UserId);
            if (dt.Rows.Count == 0)
                return null;
            else
                return TBL_UserProfile.ReadRow(dt.Rows[0]);
        }

        public DataTable select_join(long UserId)
        {
            return select_join("where UserProfile.UserId=@UserId", UserId);
        }

        public DataTable select_join()
        {
            return select_join("");
        }

        public DataTable select_join(string where_clause, params object[] inputs)
        {
            return m_db.Select(@"
					select UserProfile.UserId, UserProfile.LoginId, UserProfile.LoginPassword, UserProfile.NRIC, UserProfile.Name0, UserProfile.Address01, UserProfile.Address02, UserProfile.PostCode, UserProfile.PrimaryPhone, UserProfile.SecondaryPhone, UserProfile.FaxNumber, UserProfile.Email, UserProfile.UserTypeId, UserProfile.OrgID, UserProfile.SiteID, UserProfile.CostCentreID, UserProfile.UserStatus, UserProfile.CreatedBy, UserProfile.CreatedDatetime, UserProfile.ModifiedBy, UserProfile.ModifiedDateTime, UserProfile.LastLogin
					from UserProfile
					" + where_clause, inputs);
        }

        public void insert
        (
            ref long? UserId,
            string LoginId,
            string LoginPassword,
            string NRIC,
            string Name0,
            string Address01,
            string Address02,
            string PostCode,
            string PrimaryPhone,
            string SecondaryPhone,
            string FaxNumber,
            string Email,
            long? UserTypeId,
            long? OrgID,
            long? SiteID,
            long? CostCentreID,
            int? UserStatus,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDateTime,
            DateTime? LastLogin
        )
        {

            m_db.Exec(@"
					insert into UserProfile(
						LoginId,
						LoginPassword,
						NRIC,
						Name0,
						Address01,
						Address02,
						PostCode,
						PrimaryPhone,
						SecondaryPhone,
						FaxNumber,
						Email,
						UserTypeId,
						OrgID,
						SiteID,
						CostCentreID,
						UserStatus,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDateTime,
						LastLogin
						)
					values(
						@LoginId,
						@LoginPassword,
						@NRIC,
						@Name0,
						@Address01,
						@Address02,
						@PostCode,
						@PrimaryPhone,
						@SecondaryPhone,
						@FaxNumber,
						@Email,
						@UserTypeId,
						@OrgID,
						@SiteID,
						@CostCentreID,
						@UserStatus,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDateTime,
						@LastLogin
						)
					", LoginId, LoginPassword, NRIC, Name0, Address01, Address02, PostCode, PrimaryPhone, SecondaryPhone, FaxNumber, Email, UserTypeId, OrgID, SiteID, CostCentreID, UserStatus, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime, LastLogin);

            UserId = m_db.SelectInt("select IDENT_CURRENT('UserProfile')");
        }

        public void insert
        (
            string LoginId,
            string LoginPassword,
            string NRIC,
            string Name0,
            string Address01,
            string Address02,
            string PostCode,
            string PrimaryPhone,
            string SecondaryPhone,
            string FaxNumber,
            string Email,
            long? UserTypeId,
            long? OrgID,
            long? SiteID,
            long? CostCentreID,
            int? UserStatus,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDateTime,
            DateTime? LastLogin
        )
        {
            m_db.Exec(@"
					insert into UserProfile(
						LoginId,
						LoginPassword,
						NRIC,
						Name0,
						Address01,
						Address02,
						PostCode,
						PrimaryPhone,
						SecondaryPhone,
						FaxNumber,
						Email,
						UserTypeId,
						OrgID,
						SiteID,
						CostCentreID,
						UserStatus,
						CreatedBy,
						CreatedDatetime,
						ModifiedBy,
						ModifiedDateTime,
						LastLogin
						)
					values(
						@LoginId,
						@LoginPassword,
						@NRIC,
						@Name0,
						@Address01,
						@Address02,
						@PostCode,
						@PrimaryPhone,
						@SecondaryPhone,
						@FaxNumber,
						@Email,
						@UserTypeId,
						@OrgID,
						@SiteID,
						@CostCentreID,
						@UserStatus,
						@CreatedBy,
						@CreatedDatetime,
						@ModifiedBy,
						@ModifiedDateTime,
						@LastLogin
						)
					", LoginId, LoginPassword, NRIC, Name0, Address01, Address02, PostCode, PrimaryPhone, SecondaryPhone, FaxNumber, Email, UserTypeId, OrgID, SiteID, CostCentreID, UserStatus, CreatedBy, CreatedDatetime, ModifiedBy, ModifiedDateTime, LastLogin);
        }

        public void update
        (
            long UserId,
            string LoginId,
            string LoginPassword,
            string NRIC,
            string Name0,
            string Address01,
            string Address02,
            string PostCode,
            string PrimaryPhone,
            string SecondaryPhone,
            string FaxNumber,
            string Email,
            long? UserTypeId,
            long? OrgID,
            long? SiteID,
            long? CostCentreID,
            int? UserStatus,
            long? CreatedBy,
            DateTime? CreatedDatetime,
            long? ModifiedBy,
            DateTime? ModifiedDateTime,
            DateTime? LastLogin
        )
        {
            int count = m_db.SelectCount(@"select * from UserProfile where UserId=@UserId", UserId);
            if (count == 0)
                throw new Exception("UserProfile.update error. ID does not exists");

            m_db.Exec(@"
					update UserProfile
					set
						LoginId = @LoginId,
						LoginPassword = @LoginPassword,
						NRIC = @NRIC,
						Name0 = @Name0,
						Address01 = @Address01,
						Address02 = @Address02,
						PostCode = @PostCode,
						PrimaryPhone = @PrimaryPhone,
						SecondaryPhone = @SecondaryPhone,
						FaxNumber = @FaxNumber,
						Email = @Email,
						UserTypeId = @UserTypeId,
						OrgID = @OrgID,
						SiteID = @SiteID,
						CostCentreID = @CostCentreID,
						UserStatus = @UserStatus,
						CreatedBy = @CreatedBy,
						CreatedDatetime = @CreatedDatetime,
						ModifiedBy = @ModifiedBy,
						ModifiedDateTime = @ModifiedDateTime,
						LastLogin = @LastLogin
					where UserId=@UserId
					",
                LoginId,
                LoginPassword,
                NRIC,
                Name0,
                Address01,
                Address02,
                PostCode,
                PrimaryPhone,
                SecondaryPhone,
                FaxNumber,
                Email,
                UserTypeId,
                OrgID,
                SiteID,
                CostCentreID,
                UserStatus,
                CreatedBy,
                CreatedDatetime,
                ModifiedBy,
                ModifiedDateTime,
                LastLogin,
                UserId
            );
        }

        public void delete(long UserId)
        {
            int count = m_db.SelectCount(@"select * from UserProfile where UserId=@UserId", UserId);
            if (count == 0)
                throw new Exception("UserProfile.delete error. ID does not exists");

            m_db.Exec(@"delete from UserProfile where UserId=@UserId", UserId);
        }

    }

    #endregion


    public void sp_0
    (
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "sp_0";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_AttachmentsInChangeRequest_DeleteByChangeRequestIDRole
    (
        long ChangeRequestID,
        long ChangeRequestRole
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_AttachmentsInChangeRequest_DeleteByChangeRequestIDRole";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ChangeRequestID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ChangeRequestID);
            AddParam(cmd, "@ChangeRequestRole", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ChangeRequestRole);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_AttachmentsInChangeRequest_DeleteByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_AttachmentsInChangeRequest_DeleteByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_AttachmentsInChangeRequest_Insert
    (
        long ChangeRequestID,
        long ChangeRequestRole,
        string AttachmentName,
        byte[] AttachmentDetails,
        string AttachmentContentType,
        long CreatedBy,
        ref long xPrimaryKey
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_AttachmentsInChangeRequest_Insert";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ChangeRequestID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ChangeRequestID);
            AddParam(cmd, "@ChangeRequestRole", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ChangeRequestRole);
            AddParam(cmd, "@AttachmentName", DbType.String, 200, 100, 0, ParameterDirection.Input, AttachmentName);
            AddParam(cmd, "@AttachmentDetails", DbType.Binary, 16, 0, 0, ParameterDirection.Input, AttachmentDetails);
            AddParam(cmd, "@AttachmentContentType", DbType.String, 510, 255, 0, ParameterDirection.Input, AttachmentContentType);
            AddParam(cmd, "@CreatedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, CreatedBy);
            AddParam(cmd, "@xPrimaryKey", DbType.Int32, 8, 19, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            xPrimaryKey = get_long_value(((IDbDataParameter)cmd.Parameters["@xPrimaryKey"]).Value);
            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void sp_AttachmentsInChangeRequest_SelectByChangeRequestIDRole
    (
        long ChangeRequestID,
        long ChangeRequestRole
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "sp_AttachmentsInChangeRequest_SelectByChangeRequestIDRole";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ChangeRequestID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ChangeRequestID);
            AddParam(cmd, "@ChangeRequestRole", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ChangeRequestRole);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void sp_AttachmentsInChangeRequest_SelectByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "sp_AttachmentsInChangeRequest_SelectByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_AttachmentsInChangeRequest_UpdateByID
    (
        long ID,
        long ChangeRequestID,
        long ChangeRequestRole,
        string AttachmentName,
        byte[] AttachmentDetails,
        string AttachmentContentType
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_AttachmentsInChangeRequest_UpdateByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@ChangeRequestID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ChangeRequestID);
            AddParam(cmd, "@ChangeRequestRole", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ChangeRequestRole);
            AddParam(cmd, "@AttachmentName", DbType.String, 200, 100, 0, ParameterDirection.Input, AttachmentName);
            AddParam(cmd, "@AttachmentDetails", DbType.Binary, 16, 0, 0, ParameterDirection.Input, AttachmentDetails);
            AddParam(cmd, "@AttachmentContentType", DbType.String, 510, 255, 0, ParameterDirection.Input, AttachmentContentType);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_AttachmentsInNotice_DeleteByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_AttachmentsInNotice_DeleteByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_AttachmentsInNotice_DeleteByNoticeID
    (
        long NoticeID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_AttachmentsInNotice_DeleteByNoticeID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@NoticeID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, NoticeID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_AttachmentsInNotice_Insert
    (
        long NoticeID,
        byte[] AttachmentDetails,
        string AttachmentName,
        string AttachmentContentType,
        long CreatedBy,
        ref long xPrimaryKey
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_AttachmentsInNotice_Insert";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@NoticeID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, NoticeID);
            AddParam(cmd, "@AttachmentDetails", DbType.Binary, 16, 0, 0, ParameterDirection.Input, AttachmentDetails);
            AddParam(cmd, "@AttachmentName", DbType.String, 200, 100, 0, ParameterDirection.Input, AttachmentName);
            AddParam(cmd, "@AttachmentContentType", DbType.String, 510, 255, 0, ParameterDirection.Input, AttachmentContentType);
            AddParam(cmd, "@CreatedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, CreatedBy);
            AddParam(cmd, "@xPrimaryKey", DbType.Int32, 8, 19, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            xPrimaryKey = get_long_value(((IDbDataParameter)cmd.Parameters["@xPrimaryKey"]).Value);
            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_AttachmentsInNotice_SelectAll
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_AttachmentsInNotice_SelectAll";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void sp_AttachmentsInNotice_SelectByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "sp_AttachmentsInNotice_SelectByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_AttachmentsInNotice_SelectByNoticeID
    (
        long NoticeID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_AttachmentsInNotice_SelectByNoticeID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@NoticeID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, NoticeID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_AttachmentsInNotice_UpdateByID
    (
        long ID,
        long NoticeID,
        byte[] AttachmentDetails,
        string AttachmentName,
        string AttachmentContentType,
        long ModifiedBy
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_AttachmentsInNotice_UpdateByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@NoticeID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, NoticeID);
            AddParam(cmd, "@AttachmentDetails", DbType.Binary, 16, 0, 0, ParameterDirection.Input, AttachmentDetails);
            AddParam(cmd, "@AttachmentName", DbType.String, 200, 100, 0, ParameterDirection.Input, AttachmentName);
            AddParam(cmd, "@AttachmentContentType", DbType.String, 510, 255, 0, ParameterDirection.Input, AttachmentContentType);
            AddParam(cmd, "@ModifiedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ModifiedBy);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_AuditTrail_Insert
    (
        DateTime datetime,
        string script,
        string user,
        string action,
        string table,
        string field,
        string keyvalue,
        string oldvalue,
        string newvalue
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_AuditTrail_Insert";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@datetime", DbType.DateTime, 8, 23, 3, ParameterDirection.Input, datetime);
            AddParam(cmd, "@script", DbType.String, 510, 255, 0, ParameterDirection.Input, script);
            AddParam(cmd, "@user", DbType.String, 510, 255, 0, ParameterDirection.Input, user);
            AddParam(cmd, "@action", DbType.String, 510, 255, 0, ParameterDirection.Input, action);
            AddParam(cmd, "@table", DbType.String, 510, 255, 0, ParameterDirection.Input, table);
            AddParam(cmd, "@field", DbType.String, 510, 255, 0, ParameterDirection.Input, field);
            AddParam(cmd, "@keyvalue", DbType.String, 16, 0, 0, ParameterDirection.Input, keyvalue);
            AddParam(cmd, "@oldvalue", DbType.String, 16, 0, 0, ParameterDirection.Input, oldvalue);
            AddParam(cmd, "@newvalue", DbType.String, 16, 0, 0, ParameterDirection.Input, newvalue);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void sp_BackupDatabase
    (
        string databaseName,
        string backupType
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "sp_BackupDatabase";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@databaseName", DbType.String, 256, 128, 0, ParameterDirection.Input, databaseName);
            AddParam(cmd, "@backupType", DbType.String, 1, 1, 0, ParameterDirection.Input, backupType);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_Bill_Generate
    (
        long BillPeriodID,
        ref string GenerateOutput
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_Bill_Generate";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@BillPeriodID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
            AddParam(cmd, "@GenerateOutput", DbType.String, -1, -1, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            GenerateOutput = get_string_value(((IDbDataParameter)cmd.Parameters["@GenerateOutput"]).Value);
            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillConfig_SelectAll
    (
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillConfig_SelectAll";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillCustomer_DeleteByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillCustomer_DeleteByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillCustomer_Insert
    (
        string BillType,
        string CustNo,
        string CustName1,
        string CustName2,
        string BUCode,
        string Address,
        string ContactPerson,
        string PaymentTerm,
        string SpecialInstruction,
        string GroupBy,
        long SiteID,
        string TelNo,
        string FaxNo,
        string EmailTo,
        string Remarks,
        long CreatedBy,
        ref long xPrimaryKey
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillCustomer_Insert";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@BillType", DbType.String, 40, 20, 0, ParameterDirection.Input, BillType);
            AddParam(cmd, "@CustNo", DbType.String, 100, 50, 0, ParameterDirection.Input, CustNo);
            AddParam(cmd, "@CustName1", DbType.String, 510, 255, 0, ParameterDirection.Input, CustName1);
            AddParam(cmd, "@CustName2", DbType.String, 510, 255, 0, ParameterDirection.Input, CustName2);
            AddParam(cmd, "@BUCode", DbType.String, 100, 50, 0, ParameterDirection.Input, BUCode);
            AddParam(cmd, "@Address", DbType.String, 510, 255, 0, ParameterDirection.Input, Address);
            AddParam(cmd, "@ContactPerson", DbType.String, 510, 255, 0, ParameterDirection.Input, ContactPerson);
            AddParam(cmd, "@PaymentTerm", DbType.String, 100, 50, 0, ParameterDirection.Input, PaymentTerm);
            AddParam(cmd, "@SpecialInstruction", DbType.String, 1000, 500, 0, ParameterDirection.Input, SpecialInstruction);
            AddParam(cmd, "@GroupBy", DbType.String, 40, 20, 0, ParameterDirection.Input, GroupBy);
            AddParam(cmd, "@SiteID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, SiteID);
            AddParam(cmd, "@TelNo", DbType.String, 100, 50, 0, ParameterDirection.Input, TelNo);
            AddParam(cmd, "@FaxNo", DbType.String, 100, 50, 0, ParameterDirection.Input, FaxNo);
            AddParam(cmd, "@EmailTo", DbType.String, 510, 255, 0, ParameterDirection.Input, EmailTo);
            AddParam(cmd, "@Remarks", DbType.String, 16, 0, 0, ParameterDirection.Input, Remarks);
            AddParam(cmd, "@CreatedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, CreatedBy);
            AddParam(cmd, "@xPrimaryKey", DbType.Int32, 8, 19, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            xPrimaryKey = get_long_value(((IDbDataParameter)cmd.Parameters["@xPrimaryKey"]).Value);
            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillCustomer_SelectAll
    (
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillCustomer_SelectAll";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillCustomer_SelectByBillingRecipientEmail
    (
        string Email
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillCustomer_SelectByBillingRecipientEmail";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@Email", DbType.String, 200, 200, 0, ParameterDirection.Input, Email);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillCustomer_SelectByBillType
    (
        string BillType
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillCustomer_SelectByBillType";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@BillType", DbType.String, 40, 20, 0, ParameterDirection.Input, BillType);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillCustomer_SelectByBillTypeOrgID
    (
        string BillType,
        long OrgID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillCustomer_SelectByBillTypeOrgID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@BillType", DbType.String, 40, 20, 0, ParameterDirection.Input, BillType);
            AddParam(cmd, "@OrgID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, OrgID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillCustomer_SelectByBillTypeSiteID
    (
        string BillType,
        long SiteID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillCustomer_SelectByBillTypeSiteID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@BillType", DbType.String, 40, 20, 0, ParameterDirection.Input, BillType);
            AddParam(cmd, "@SiteID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, SiteID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillCustomer_SelectByBillTypeSiteIDCostCentreID
    (
        string BillType,
        long SiteID,
        long CostCentreID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillCustomer_SelectByBillTypeSiteIDCostCentreID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@BillType", DbType.String, 40, 20, 0, ParameterDirection.Input, BillType);
            AddParam(cmd, "@SiteID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, SiteID);
            AddParam(cmd, "@CostCentreID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, CostCentreID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillCustomer_SelectByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillCustomer_SelectByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillCustomer_UpdateByID
    (
        long ID,
        string BillType,
        string CustNo,
        string CustName1,
        string CustName2,
        string BUCode,
        string Address,
        string ContactPerson,
        string PaymentTerm,
        string SpecialInstruction,
        string GroupBy,
        long SiteID,
        string TelNo,
        string FaxNo,
        string EmailTo,
        string Remarks,
        long ModifiedBy
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillCustomer_UpdateByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@BillType", DbType.String, 40, 20, 0, ParameterDirection.Input, BillType);
            AddParam(cmd, "@CustNo", DbType.String, 100, 50, 0, ParameterDirection.Input, CustNo);
            AddParam(cmd, "@CustName1", DbType.String, 510, 255, 0, ParameterDirection.Input, CustName1);
            AddParam(cmd, "@CustName2", DbType.String, 510, 255, 0, ParameterDirection.Input, CustName2);
            AddParam(cmd, "@BUCode", DbType.String, 100, 50, 0, ParameterDirection.Input, BUCode);
            AddParam(cmd, "@Address", DbType.String, 510, 255, 0, ParameterDirection.Input, Address);
            AddParam(cmd, "@ContactPerson", DbType.String, 510, 255, 0, ParameterDirection.Input, ContactPerson);
            AddParam(cmd, "@PaymentTerm", DbType.String, 100, 50, 0, ParameterDirection.Input, PaymentTerm);
            AddParam(cmd, "@SpecialInstruction", DbType.String, 1000, 500, 0, ParameterDirection.Input, SpecialInstruction);
            AddParam(cmd, "@GroupBy", DbType.String, 40, 20, 0, ParameterDirection.Input, GroupBy);
            AddParam(cmd, "@SiteID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, SiteID);
            AddParam(cmd, "@TelNo", DbType.String, 100, 50, 0, ParameterDirection.Input, TelNo);
            AddParam(cmd, "@FaxNo", DbType.String, 100, 50, 0, ParameterDirection.Input, FaxNo);
            AddParam(cmd, "@EmailTo", DbType.String, 510, 255, 0, ParameterDirection.Input, EmailTo);
            AddParam(cmd, "@Remarks", DbType.String, 16, 0, 0, ParameterDirection.Input, Remarks);
            AddParam(cmd, "@ModifiedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ModifiedBy);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillCustomerCC_DeleteByBillCustomerID
    (
        long BillCustomerID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillCustomerCC_DeleteByBillCustomerID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@BillCustomerID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillCustomerID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillCustomerCC_DeleteByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillCustomerCC_DeleteByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillCustomerCC_Insert
    (
        long BillCustomerID,
        long CostCentreID,
        ref long xPrimaryKey
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillCustomerCC_Insert";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@BillCustomerID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillCustomerID);
            AddParam(cmd, "@CostCentreID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, CostCentreID);
            AddParam(cmd, "@xPrimaryKey", DbType.Int32, 8, 19, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            xPrimaryKey = get_long_value(((IDbDataParameter)cmd.Parameters["@xPrimaryKey"]).Value);
            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillCustomerCC_SelectByBillCustomerID
    (
        long BillCustomerID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillCustomerCC_SelectByBillCustomerID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@BillCustomerID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillCustomerID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillCustomerCC_SelectByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillCustomerCC_SelectByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillCustomerCC_UpdateByID
    (
        long ID,
        long BillCustomerID,
        long CostCentreID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillCustomerCC_UpdateByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@BillCustomerID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillCustomerID);
            AddParam(cmd, "@CostCentreID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, CostCentreID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillMonthly_Generate
    (
        long BillPeriodID,
        ref string GenerateOutput
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillMonthly_Generate";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@BillPeriodID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
            AddParam(cmd, "@GenerateOutput", DbType.String, -1, -1, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            GenerateOutput = get_string_value(((IDbDataParameter)cmd.Parameters["@GenerateOutput"]).Value);
            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillMonthly_IsExists
    (
        long BillPeriodID,
        ref int IsExists
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillMonthly_IsExists";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@BillPeriodID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
            AddParam(cmd, "@IsExists", DbType.Int32, 1, 1, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            IsExists = get_int_value(((IDbDataParameter)cmd.Parameters["@IsExists"]).Value);
            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillMonthly_SelectbyBillPeriodBillCustomer
    (
        long BillPeriodID,
        long BillReportTemplateID,
        long BillCustomerID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillMonthly_SelectbyBillPeriodBillCustomer";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@BillPeriodID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
            AddParam(cmd, "@BillReportTemplateID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillReportTemplateID);
            AddParam(cmd, "@BillCustomerID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillCustomerID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillMonthly_SelectByBillPeriodCostCentre
    (
        long BillPeriodID,
        long BillReportTemplateID,
        long CostCentreID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillMonthly_SelectByBillPeriodCostCentre";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@BillPeriodID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
            AddParam(cmd, "@BillReportTemplateID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillReportTemplateID);
            AddParam(cmd, "@CostCentreID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, CostCentreID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillMonthly_SelectbyBillPeriodSite
    (
        long BillPeriodID,
        long SiteID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillMonthly_SelectbyBillPeriodSite";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@BillPeriodID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
            AddParam(cmd, "@SiteID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, SiteID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillPeriod_SelectAll
    (
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillPeriod_SelectAll";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillPeriod_SelectCurrentPreiod
    (
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillPeriod_SelectCurrentPreiod";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillPeriod_SelectGeneratedDataPeriod
    (
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillPeriod_SelectGeneratedDataPeriod";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillPeriod_SelectGeneratedPeriod
    (
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillPeriod_SelectGeneratedPeriod";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillPeriod_SelectReleasedPeriodByBillingRecipientEmail
    (
        long UserID,
        string Email
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillPeriod_SelectReleasedPeriodByBillingRecipientEmail";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@UserID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, UserID);
            AddParam(cmd, "@Email", DbType.String, 200, 200, 0, ParameterDirection.Input, Email);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillPeriod_SelectReleasedPeriodBySiteID
    (
        long SiteID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillPeriod_SelectReleasedPeriodBySiteID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@SiteID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, SiteID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillQuarterly_SelectByBillPeriodCostCentre
    (
        long BillPeriodID,
        long BillReportTemplateID,
        long CostCentreID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillQuarterly_SelectByBillPeriodCostCentre";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@BillPeriodID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
            AddParam(cmd, "@BillReportTemplateID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillReportTemplateID);
            AddParam(cmd, "@CostCentreID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, CostCentreID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReport_CCTransferRequest_SelectByBillPeriod
    (
        long BillPeriodID,
        long BillReportTemplateID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReport_CCTransferRequest_SelectByBillPeriod";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@BillPeriodID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
            AddParam(cmd, "@BillReportTemplateID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillReportTemplateID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReport_ChangeRequest_SelectClosedByBillPeriod
    (
        long BillPeriodID,
        long BillReportTemplateID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReport_ChangeRequest_SelectClosedByBillPeriod";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@BillPeriodID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
            AddParam(cmd, "@BillReportTemplateID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillReportTemplateID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReport_CreationRequest_SelectByBillPeriod
    (
        long BillPeriodID,
        long BillReportTemplateID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReport_CreationRequest_SelectByBillPeriod";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@BillPeriodID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
            AddParam(cmd, "@BillReportTemplateID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillReportTemplateID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReport_FinanceSummary_SelectByBillPeriod
    (
        long BillPeriodID,
        long BillReportTemplateID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReport_FinanceSummary_SelectByBillPeriod";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@BillPeriodID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
            AddParam(cmd, "@BillReportTemplateID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillReportTemplateID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReport_ProfileList_SelectByBillPeriod
    (
        long BillPeriodID,
        long BillReportTemplateID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReport_ProfileList_SelectByBillPeriod";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@BillPeriodID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
            AddParam(cmd, "@BillReportTemplateID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillReportTemplateID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReport_RequestList_SelectByBillPeriod
    (
        long BillPeriodID,
        long BillReportTemplateID,
        long CostCentreID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReport_RequestList_SelectByBillPeriod";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@BillPeriodID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
            AddParam(cmd, "@BillReportTemplateID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillReportTemplateID);
            AddParam(cmd, "@CostCentreID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, CostCentreID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReport_TerminationRequest_SelectByBillPeriod
    (
        long BillPeriodID,
        long BillReportTemplateID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReport_TerminationRequest_SelectByBillPeriod";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@BillPeriodID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
            AddParam(cmd, "@BillReportTemplateID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillReportTemplateID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReport_UpdateVersion
    (
        long BillPeriodID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReport_UpdateVersion";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@BillPeriodID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public DataSet sp_BillReportData_select(
        long new_id,
        long old_id
    )
    {
        IDbDataAdapter da = null;
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "sp_BillReportData_select";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@new_id", DbType.Int32, 8, 19, 0, ParameterDirection.Input, new_id);
            AddParam(cmd, "@old_id", DbType.Int32, 8, 19, 0, ParameterDirection.Input, old_id);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);

            da = CreateDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds);
            return ds;
        }
        finally
        {
            if (da != null) da = null;
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }

    public void Sp_BillReportRepository_DeleteByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReportRepository_DeleteByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReportRepository_DeleteByID2
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReportRepository_DeleteByID2";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReportRepository_DeleteOldVersionByBillPeriodIDBillReportTemplateIDBillCustomerID
    (
        long BillPeriodID,
        long BillReportTemplateID,
        long BillCustomerID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReportRepository_DeleteOldVersionByBillPeriodIDBillReportTemplateIDBillCustomerID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@BillPeriodID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
            AddParam(cmd, "@BillReportTemplateID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillReportTemplateID);
            AddParam(cmd, "@BillCustomerID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillCustomerID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReportRepository_DeleteOldVersionByBillPeriodIDBillReportTemplateIDSiteIDCostCentreID
    (
        long BillPeriodID,
        long BillReportTemplateID,
        long SiteID,
        long CostCentreID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReportRepository_DeleteOldVersionByBillPeriodIDBillReportTemplateIDSiteIDCostCentreID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@BillPeriodID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
            AddParam(cmd, "@BillReportTemplateID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillReportTemplateID);
            AddParam(cmd, "@SiteID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, SiteID);
            AddParam(cmd, "@CostCentreID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, CostCentreID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReportRepository_Insert
    (
        long BillPeriodID,
        long BillReportTemplateID,
        string ReportFileName,
        byte[] ReportData,
        string ContentType,
        int IsReleased,
        long SiteID,
        long CostCentreID,
        long CreatedBy,
        string DownloadID,
        long BillCustomerID,
        int Version,
        int IsLatest,
        string Thumbnail,
        ref long xPrimaryKey
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReportRepository_Insert";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@BillPeriodID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
            AddParam(cmd, "@BillReportTemplateID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillReportTemplateID);
            AddParam(cmd, "@ReportFileName", DbType.String, 510, 255, 0, ParameterDirection.Input, ReportFileName);
            AddParam(cmd, "@ReportData", DbType.Binary, 16, 0, 0, ParameterDirection.Input, ReportData);
            AddParam(cmd, "@ContentType", DbType.String, 510, 255, 0, ParameterDirection.Input, ContentType);
            AddParam(cmd, "@IsReleased", DbType.Int32, 1, 1, 0, ParameterDirection.Input, IsReleased);
            AddParam(cmd, "@SiteID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, SiteID);
            AddParam(cmd, "@CostCentreID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, CostCentreID);
            AddParam(cmd, "@CreatedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, CreatedBy);
            AddParam(cmd, "@DownloadID", DbType.String, 72, 36, 0, ParameterDirection.Input, DownloadID);
            AddParam(cmd, "@BillCustomerID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillCustomerID);
            AddParam(cmd, "@Version", DbType.Int32, 4, 10, 0, ParameterDirection.Input, Version);
            AddParam(cmd, "@IsLatest", DbType.Int32, 4, 10, 0, ParameterDirection.Input, IsLatest);
            AddParam(cmd, "@Thumbnail", DbType.String, 510, 255, 0, ParameterDirection.Input, Thumbnail);
            AddParam(cmd, "@xPrimaryKey", DbType.Int32, 8, 19, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            xPrimaryKey = get_long_value(((IDbDataParameter)cmd.Parameters["@xPrimaryKey"]).Value);
            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReportRepository_ReleaseByID
    (
        long ID,
        long ReleasedBy,
        ref int UpdatedRow
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReportRepository_ReleaseByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@ReleasedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ReleasedBy);
            AddParam(cmd, "@UpdatedRow", DbType.Int32, 4, 10, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            UpdatedRow = get_int_value(((IDbDataParameter)cmd.Parameters["@UpdatedRow"]).Value);
            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReportRepository_SelectAllReleasedWithoutDataByPeriodLoginGroupLoginEmailBillCustomer
    (
        long BillPeriodID,
        long LoginUserGroup,
        long UserID,
        string Email,
        long BillCustomerID,
        int IncludeOldVersion
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReportRepository_SelectAllReleasedWithoutDataByPeriodLoginGroupLoginEmailBillCustomer";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@BillPeriodID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
            AddParam(cmd, "@LoginUserGroup", DbType.Int32, 8, 19, 0, ParameterDirection.Input, LoginUserGroup);
            AddParam(cmd, "@UserID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, UserID);
            AddParam(cmd, "@Email", DbType.String, 200, 200, 0, ParameterDirection.Input, Email);
            AddParam(cmd, "@BillCustomerID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillCustomerID);
            AddParam(cmd, "@IncludeOldVersion", DbType.Int32, 4, 10, 0, ParameterDirection.Input, IncludeOldVersion);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReportRepository_SelectAllReleasedWithoutDataByPeriodLoginGroupLoginSiteOrgSiteCC
    (
        long BillPeriodID,
        long LoginUserGroup,
        long LoginSiteID,
        long OrgID,
        long SiteID,
        long CostCentreID,
        int IncludeOldVersion
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReportRepository_SelectAllReleasedWithoutDataByPeriodLoginGroupLoginSiteOrgSiteCC";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@BillPeriodID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
            AddParam(cmd, "@LoginUserGroup", DbType.Int32, 8, 19, 0, ParameterDirection.Input, LoginUserGroup);
            AddParam(cmd, "@LoginSiteID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, LoginSiteID);
            AddParam(cmd, "@OrgID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, OrgID);
            AddParam(cmd, "@SiteID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, SiteID);
            AddParam(cmd, "@CostCentreID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, CostCentreID);
            AddParam(cmd, "@IncludeOldVersion", DbType.Int32, 4, 10, 0, ParameterDirection.Input, IncludeOldVersion);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReportRepository_SelectAllWithoutDataByPeriodOrgSiteCC
    (
        long BillPeriodID,
        long OrgID,
        long SiteID,
        long CostCentreID,
        int FilterByIsReleased,
        int IsReleased,
        int IncludeOldVersion
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReportRepository_SelectAllWithoutDataByPeriodOrgSiteCC";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@BillPeriodID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
            AddParam(cmd, "@OrgID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, OrgID);
            AddParam(cmd, "@SiteID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, SiteID);
            AddParam(cmd, "@CostCentreID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, CostCentreID);
            AddParam(cmd, "@FilterByIsReleased", DbType.Int32, 1, 1, 0, ParameterDirection.Input, FilterByIsReleased);
            AddParam(cmd, "@IsReleased", DbType.Int32, 1, 1, 0, ParameterDirection.Input, IsReleased);
            AddParam(cmd, "@IncludeOldVersion", DbType.Int32, 4, 10, 0, ParameterDirection.Input, IncludeOldVersion);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReportRepository_SelectBillingRecipientUserIdBySelectedRepositoryID
    (
        string SelectedRepositoryIDList
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReportRepository_SelectBillingRecipientUserIdBySelectedRepositoryID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@SelectedRepositoryIDList", DbType.String, -1, -1, 0, ParameterDirection.Input, SelectedRepositoryIDList);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReportRepository_SelectByBillPeriodIDBillReportTemplateIDBillCustomerID
    (
        long BillPeriodID,
        long BillReportTemplateID,
        long BillCustomerID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReportRepository_SelectByBillPeriodIDBillReportTemplateIDBillCustomerID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@BillPeriodID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
            AddParam(cmd, "@BillReportTemplateID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillReportTemplateID);
            AddParam(cmd, "@BillCustomerID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillCustomerID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReportRepository_SelectByBillPeriodIDBillReportTemplateIDSiteIDCostCentreID
    (
        long BillPeriodID,
        long BillReportTemplateID,
        long SiteID,
        long CostCentreID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReportRepository_SelectByBillPeriodIDBillReportTemplateIDSiteIDCostCentreID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@BillPeriodID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
            AddParam(cmd, "@BillReportTemplateID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillReportTemplateID);
            AddParam(cmd, "@SiteID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, SiteID);
            AddParam(cmd, "@CostCentreID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, CostCentreID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReportRepository_SelectByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReportRepository_SelectByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReportRepository_SelectByIDDownloadID
    (
        long ID,
        string DownloadID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReportRepository_SelectByIDDownloadID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@DownloadID", DbType.String, 72, 36, 0, ParameterDirection.Input, DownloadID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReportRepository_SelectBySelectedRepositoryIDBillingRecipientUserId
    (
        string SelectedRepositoryIDList,
        long UserId
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReportRepository_SelectBySelectedRepositoryIDBillingRecipientUserId";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@SelectedRepositoryIDList", DbType.String, -1, -1, 0, ParameterDirection.Input, SelectedRepositoryIDList);
            AddParam(cmd, "@UserId", DbType.Int32, 8, 19, 0, ParameterDirection.Input, UserId);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReportRepository_SelectBySelectedRepositoryIDGroupMemberID
    (
        string SelectedRepositoryIDList,
        long GroupMemberID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReportRepository_SelectBySelectedRepositoryIDGroupMemberID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@SelectedRepositoryIDList", DbType.String, -1, -1, 0, ParameterDirection.Input, SelectedRepositoryIDList);
            AddParam(cmd, "@GroupMemberID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, GroupMemberID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReportRepository_SelectBySelectedRepositoryIDGroupMemberIDSiteID
    (
        string SelectedRepositoryIDList,
        long GroupMemberID,
        long SiteID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReportRepository_SelectBySelectedRepositoryIDGroupMemberIDSiteID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@SelectedRepositoryIDList", DbType.String, -1, -1, 0, ParameterDirection.Input, SelectedRepositoryIDList);
            AddParam(cmd, "@GroupMemberID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, GroupMemberID);
            AddParam(cmd, "@SiteID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, SiteID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReportRepository_SelectGroupMemberIDWithNoSiteIDBySelectedRepositoryID
    (
        string SelectedRepositoryIDList
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReportRepository_SelectGroupMemberIDWithNoSiteIDBySelectedRepositoryID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@SelectedRepositoryIDList", DbType.String, -1, -1, 0, ParameterDirection.Input, SelectedRepositoryIDList);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReportRepository_SelectGroupMemberIDWithSiteIDBySelectedRepositoryID
    (
        string SelectedRepositoryIDList
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReportRepository_SelectGroupMemberIDWithSiteIDBySelectedRepositoryID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@SelectedRepositoryIDList", DbType.String, -1, -1, 0, ParameterDirection.Input, SelectedRepositoryIDList);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReportRepository_SelectPreviousVersionByBillPeriodIDBillReportTemplateIDBillCustomerID
    (
        long BillPeriodID,
        long BillReportTemplateID,
        long BillCustomerID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReportRepository_SelectPreviousVersionByBillPeriodIDBillReportTemplateIDBillCustomerID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@BillPeriodID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
            AddParam(cmd, "@BillReportTemplateID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillReportTemplateID);
            AddParam(cmd, "@BillCustomerID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillCustomerID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReportRepository_SelectPreviousVersionByBillPeriodIDBillReportTemplateIDSiteIDCostCentreID
    (
        long BillPeriodID,
        long BillReportTemplateID,
        long SiteID,
        long CostCentreID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReportRepository_SelectPreviousVersionByBillPeriodIDBillReportTemplateIDSiteIDCostCentreID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@BillPeriodID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
            AddParam(cmd, "@BillReportTemplateID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillReportTemplateID);
            AddParam(cmd, "@SiteID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, SiteID);
            AddParam(cmd, "@CostCentreID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, CostCentreID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReportRepository_UnReleaseByID
    (
        long ID,
        long UnReleasedBy,
        ref int UpdatedRow
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReportRepository_UnReleaseByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@UnReleasedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, UnReleasedBy);
            AddParam(cmd, "@UpdatedRow", DbType.Int32, 4, 10, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            UpdatedRow = get_int_value(((IDbDataParameter)cmd.Parameters["@UpdatedRow"]).Value);
            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReportRepository_UpdateByID
    (
        long ID,
        long BillPeriodID,
        long BillReportTemplateID,
        string ReportFileName,
        byte[] ReportData,
        string ContentType,
        int IsReleased,
        long SiteID,
        long CostCentreID,
        long CreatedBy,
        DateTime CreatedDateTime,
        long ReleasedBy,
        DateTime ReleasedDateTime
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReportRepository_UpdateByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@BillPeriodID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillPeriodID);
            AddParam(cmd, "@BillReportTemplateID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillReportTemplateID);
            AddParam(cmd, "@ReportFileName", DbType.String, 510, 255, 0, ParameterDirection.Input, ReportFileName);
            AddParam(cmd, "@ReportData", DbType.Binary, 16, 0, 0, ParameterDirection.Input, ReportData);
            AddParam(cmd, "@ContentType", DbType.String, 510, 255, 0, ParameterDirection.Input, ContentType);
            AddParam(cmd, "@IsReleased", DbType.Int32, 1, 1, 0, ParameterDirection.Input, IsReleased);
            AddParam(cmd, "@SiteID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, SiteID);
            AddParam(cmd, "@CostCentreID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, CostCentreID);
            AddParam(cmd, "@CreatedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, CreatedBy);
            AddParam(cmd, "@CreatedDateTime", DbType.DateTime, 8, 23, 3, ParameterDirection.Input, CreatedDateTime);
            AddParam(cmd, "@ReleasedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ReleasedBy);
            AddParam(cmd, "@ReleasedDateTime", DbType.DateTime, 8, 23, 3, ParameterDirection.Input, ReleasedDateTime);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReportTemplate_DeleteByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReportTemplate_DeleteByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReportTemplate_Insert
    (
        string ReportName,
        string ReportPath,
        string RenderFormat,
        string ReportFileExt,
        string ContentType,
        string DatasetName,
        string StoredProcName,
        string ParameterType,
        int ReportStatus,
        string BillType,
        ref long xPrimaryKey
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReportTemplate_Insert";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ReportName", DbType.String, 510, 255, 0, ParameterDirection.Input, ReportName);
            AddParam(cmd, "@ReportPath", DbType.String, 510, 255, 0, ParameterDirection.Input, ReportPath);
            AddParam(cmd, "@RenderFormat", DbType.String, 100, 50, 0, ParameterDirection.Input, RenderFormat);
            AddParam(cmd, "@ReportFileExt", DbType.String, 20, 10, 0, ParameterDirection.Input, ReportFileExt);
            AddParam(cmd, "@ContentType", DbType.String, 510, 255, 0, ParameterDirection.Input, ContentType);
            AddParam(cmd, "@DatasetName", DbType.String, 510, 255, 0, ParameterDirection.Input, DatasetName);
            AddParam(cmd, "@StoredProcName", DbType.String, 510, 255, 0, ParameterDirection.Input, StoredProcName);
            AddParam(cmd, "@ParameterType", DbType.String, 510, 255, 0, ParameterDirection.Input, ParameterType);
            AddParam(cmd, "@ReportStatus", DbType.Int32, 1, 1, 0, ParameterDirection.Input, ReportStatus);
            AddParam(cmd, "@BillType", DbType.String, 40, 20, 0, ParameterDirection.Input, BillType);
            AddParam(cmd, "@xPrimaryKey", DbType.Int32, 8, 19, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            xPrimaryKey = get_long_value(((IDbDataParameter)cmd.Parameters["@xPrimaryKey"]).Value);
            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReportTemplate_SelectAllActive
    (
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReportTemplate_SelectAllActive";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReportTemplate_SelectByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReportTemplate_SelectByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReportTemplate_UpdateByID
    (
        long ID,
        string ReportName,
        string ReportPath,
        string RenderFormat,
        string ReportFileExt,
        string ContentType,
        string DatasetName,
        string StoredProcName,
        string ParameterType,
        int ReportStatus,
        string BillType
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReportTemplate_UpdateByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@ReportName", DbType.String, 510, 255, 0, ParameterDirection.Input, ReportName);
            AddParam(cmd, "@ReportPath", DbType.String, 510, 255, 0, ParameterDirection.Input, ReportPath);
            AddParam(cmd, "@RenderFormat", DbType.String, 100, 50, 0, ParameterDirection.Input, RenderFormat);
            AddParam(cmd, "@ReportFileExt", DbType.String, 20, 10, 0, ParameterDirection.Input, ReportFileExt);
            AddParam(cmd, "@ContentType", DbType.String, 510, 255, 0, ParameterDirection.Input, ContentType);
            AddParam(cmd, "@DatasetName", DbType.String, 510, 255, 0, ParameterDirection.Input, DatasetName);
            AddParam(cmd, "@StoredProcName", DbType.String, 510, 255, 0, ParameterDirection.Input, StoredProcName);
            AddParam(cmd, "@ParameterType", DbType.String, 510, 255, 0, ParameterDirection.Input, ParameterType);
            AddParam(cmd, "@ReportStatus", DbType.Int32, 1, 1, 0, ParameterDirection.Input, ReportStatus);
            AddParam(cmd, "@BillType", DbType.String, 40, 20, 0, ParameterDirection.Input, BillType);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReportUserGroup_DeleteByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReportUserGroup_DeleteByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReportUserGroup_Insert
    (
        long BillReportTemplateID,
        long GroupMemberID,
        ref long xPrimaryKey
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReportUserGroup_Insert";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@BillReportTemplateID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillReportTemplateID);
            AddParam(cmd, "@GroupMemberID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, GroupMemberID);
            AddParam(cmd, "@xPrimaryKey", DbType.Int32, 8, 19, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            xPrimaryKey = get_long_value(((IDbDataParameter)cmd.Parameters["@xPrimaryKey"]).Value);
            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReportUserGroup_SelectByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReportUserGroup_SelectByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_BillReportUserGroup_UpdateByID
    (
        long ID,
        long BillReportTemplateID,
        long GroupMemberID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_BillReportUserGroup_UpdateByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@BillReportTemplateID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, BillReportTemplateID);
            AddParam(cmd, "@GroupMemberID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, GroupMemberID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_ChangeRequest_DeleteByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_ChangeRequest_DeleteByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_ChangeRequest_Insert
    (
        string ChangeRequestNo,
        long ChangeRequestTypeID,
        long ChangeRequestStatus,
        string RequestorComment,
        long CreatedBy,
        ref long xPrimaryKey
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_ChangeRequest_Insert";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ChangeRequestNo", DbType.String, 100, 50, 0, ParameterDirection.Input, ChangeRequestNo);
            AddParam(cmd, "@ChangeRequestTypeID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ChangeRequestTypeID);
            AddParam(cmd, "@ChangeRequestStatus", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ChangeRequestStatus);
            AddParam(cmd, "@RequestorComment", DbType.String, -1, -1, 0, ParameterDirection.Input, RequestorComment);
            AddParam(cmd, "@CreatedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, CreatedBy);
            AddParam(cmd, "@xPrimaryKey", DbType.Int32, 8, 19, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            xPrimaryKey = get_long_value(((IDbDataParameter)cmd.Parameters["@xPrimaryKey"]).Value);
            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_ChangeRequest_SelectByChangeRequestStatus
    (
        long ChangeRequestStatus
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_ChangeRequest_SelectByChangeRequestStatus";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ChangeRequestStatus", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ChangeRequestStatus);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_ChangeRequest_SelectByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_ChangeRequest_SelectByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_ChangeRequest_SelectByIDForReport
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_ChangeRequest_SelectByIDForReport";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_ChangeRequest_SelectByIDForTemplate
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_ChangeRequest_SelectByIDForTemplate";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_ChangeRequest_SelectByLoginID
    (
        string LoginID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_ChangeRequest_SelectByLoginID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@LoginID", DbType.String, 200, 100, 0, ParameterDirection.Input, LoginID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_ChangeRequest_SelectTodayMaxCRNo
    (
        long ChangeRequestStatus
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_ChangeRequest_SelectTodayMaxCRNo";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ChangeRequestStatus", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ChangeRequestStatus);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_ChangeRequest_UpdateByID
    (
        long ID,
        string ChangeRequestNo,
        long ChangeRequestTypeID,
        long ChangeRequestStatus,
        string RequestorComment,
        long ModifiedBy
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_ChangeRequest_UpdateByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@ChangeRequestNo", DbType.String, 100, 50, 0, ParameterDirection.Input, ChangeRequestNo);
            AddParam(cmd, "@ChangeRequestTypeID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ChangeRequestTypeID);
            AddParam(cmd, "@ChangeRequestStatus", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ChangeRequestStatus);
            AddParam(cmd, "@RequestorComment", DbType.String, -1, -1, 0, ParameterDirection.Input, RequestorComment);
            AddParam(cmd, "@ModifiedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ModifiedBy);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_ChangeRequestForm_Clear
    (
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_ChangeRequestForm_Clear";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_ChangeRequestReason_SelectAll
    (
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_ChangeRequestReason_SelectAll";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_ChangeRequestRoleGroup_DeleteByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_ChangeRequestRoleGroup_DeleteByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_ChangeRequestRoleGroup_Insert
    (
        long ChangeRequestRoleID,
        long GroupMemberID,
        DateTime CreatedBy,
        DateTime CreatedDatetime,
        long ModifiedBy,
        DateTime ModifiedDatetime,
        ref long xPrimaryKey
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_ChangeRequestRoleGroup_Insert";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ChangeRequestRoleID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ChangeRequestRoleID);
            AddParam(cmd, "@GroupMemberID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, GroupMemberID);
            AddParam(cmd, "@CreatedBy", DbType.DateTime, 8, 23, 3, ParameterDirection.Input, CreatedBy);
            AddParam(cmd, "@CreatedDatetime", DbType.DateTime, 8, 23, 3, ParameterDirection.Input, CreatedDatetime);
            AddParam(cmd, "@ModifiedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ModifiedBy);
            AddParam(cmd, "@ModifiedDatetime", DbType.DateTime, 8, 23, 3, ParameterDirection.Input, ModifiedDatetime);
            AddParam(cmd, "@xPrimaryKey", DbType.Int32, 8, 19, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            xPrimaryKey = get_long_value(((IDbDataParameter)cmd.Parameters["@xPrimaryKey"]).Value);
            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_ChangeRequestRoleGroup_MatchUserCRRole
    (
        long UseId,
        long ChangeRequestRoleID,
        ref int IsMatch
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_ChangeRequestRoleGroup_MatchUserCRRole";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@UseId", DbType.Int32, 8, 19, 0, ParameterDirection.Input, UseId);
            AddParam(cmd, "@ChangeRequestRoleID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ChangeRequestRoleID);
            AddParam(cmd, "@IsMatch", DbType.Int32, 1, 1, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            IsMatch = get_int_value(((IDbDataParameter)cmd.Parameters["@IsMatch"]).Value);
            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_ChangeRequestRoleGroup_SelectByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_ChangeRequestRoleGroup_SelectByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_ChangeRequestRoleGroup_UpdateByID
    (
        long ID,
        long ChangeRequestRoleID,
        long GroupMemberID,
        long ModifiedBy
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_ChangeRequestRoleGroup_UpdateByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@ChangeRequestRoleID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ChangeRequestRoleID);
            AddParam(cmd, "@GroupMemberID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, GroupMemberID);
            AddParam(cmd, "@ModifiedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ModifiedBy);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_ChangeRequestStatus_SelectAll
    (
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_ChangeRequestStatus_SelectAll";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_ChangeRequestType_SelectAll
    (
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_ChangeRequestType_SelectAll";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void SP_Content_Valid
    (
        int UserID,
        string ContentType,
        string ContentID,
        ref int Valid
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "SP_Content_Valid";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@UserID", DbType.Int32, 4, 10, 0, ParameterDirection.Input, UserID);
            AddParam(cmd, "@ContentType", DbType.String, 100, 100, 0, ParameterDirection.Input, ContentType);
            AddParam(cmd, "@ContentID", DbType.String, 100, 100, 0, ParameterDirection.Input, ContentID);
            AddParam(cmd, "@Valid", DbType.Int32, 4, 10, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            Valid = get_int_value(((IDbDataParameter)cmd.Parameters["@Valid"]).Value);
            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_CostCentresInSite_DeleteByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_CostCentresInSite_DeleteByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_CostCentresInSite_Insert
    (
        long SiteID,
        string CostCentreIDName,
        string CostCentreName,
        int CostCentreStatus,
        long CreatedBy,
        ref int xPrimaryKey
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_CostCentresInSite_Insert";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@SiteID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, SiteID);
            AddParam(cmd, "@CostCentreIDName", DbType.String, 400, 200, 0, ParameterDirection.Input, CostCentreIDName);
            AddParam(cmd, "@CostCentreName", DbType.String, 400, 200, 0, ParameterDirection.Input, CostCentreName);
            AddParam(cmd, "@CostCentreStatus", DbType.Int32, 1, 1, 0, ParameterDirection.Input, CostCentreStatus);
            AddParam(cmd, "@CreatedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, CreatedBy);
            AddParam(cmd, "@xPrimaryKey", DbType.Int32, 4, 10, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            xPrimaryKey = get_int_value(((IDbDataParameter)cmd.Parameters["@xPrimaryKey"]).Value);
            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_CostCentresInSite_SelectActiveBySiteID
    (
        long SiteID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_CostCentresInSite_SelectActiveBySiteID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@SiteID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, SiteID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_CostCentresInSite_SelectAll
    (
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_CostCentresInSite_SelectAll";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_CostCentresInSite_SelectByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_CostCentresInSite_SelectByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_CostCentresInSite_SelectBySiteID
    (
        long SiteID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_CostCentresInSite_SelectBySiteID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@SiteID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, SiteID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_CostCentresInSite_SelectOrgSiteCCByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_CostCentresInSite_SelectOrgSiteCCByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_CostCentresInSite_SelectOrgSiteCCByOrgID
    (
        long OrgID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_CostCentresInSite_SelectOrgSiteCCByOrgID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@OrgID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, OrgID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_CostCentresInSite_UpdateByID
    (
        long ID,
        long SiteID,
        string CostCentreIDName,
        string CostCentreName,
        int CostCentreStatus,
        long ModifiedBy
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_CostCentresInSite_UpdateByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@SiteID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, SiteID);
            AddParam(cmd, "@CostCentreIDName", DbType.String, 400, 200, 0, ParameterDirection.Input, CostCentreIDName);
            AddParam(cmd, "@CostCentreName", DbType.String, 400, 200, 0, ParameterDirection.Input, CostCentreName);
            AddParam(cmd, "@CostCentreStatus", DbType.Int32, 1, 1, 0, ParameterDirection.Input, CostCentreStatus);
            AddParam(cmd, "@ModifiedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ModifiedBy);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void SP_DetailsInChangeRequest_DeleteByChangeRequestID
    (
        long ChangeRequestID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "SP_DetailsInChangeRequest_DeleteByChangeRequestID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ChangeRequestID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ChangeRequestID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void SP_DetailsInChangeRequest_Insert
    (
        long ChangeRequestID,
        long SubscriberID,
        long New_CostCentreID,
        DateTime New_EffectiveDate,
        DateTime New_TerminatedDate,
        string New_Email,
        string New_Username,
        string New_ServiceType,
        string New_AssetID,
        string New_Hostname,
        string New_OS,
        int New_Status,
        ref long xPrimaryKey
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "SP_DetailsInChangeRequest_Insert";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ChangeRequestID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ChangeRequestID);
            AddParam(cmd, "@SubscriberID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, SubscriberID);
            AddParam(cmd, "@New_CostCentreID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, New_CostCentreID);
            AddParam(cmd, "@New_EffectiveDate", DbType.DateTime, 8, 23, 3, ParameterDirection.Input, New_EffectiveDate);
            AddParam(cmd, "@New_TerminatedDate", DbType.DateTime, 8, 23, 3, ParameterDirection.Input, New_TerminatedDate);
            AddParam(cmd, "@New_Email", DbType.String, 400, 200, 0, ParameterDirection.Input, New_Email);
            AddParam(cmd, "@New_Username", DbType.String, 100, 50, 0, ParameterDirection.Input, New_Username);
            AddParam(cmd, "@New_ServiceType", DbType.String, 100, 50, 0, ParameterDirection.Input, New_ServiceType);
            AddParam(cmd, "@New_AssetID", DbType.String, 100, 50, 0, ParameterDirection.Input, New_AssetID);
            AddParam(cmd, "@New_Hostname", DbType.String, 100, 50, 0, ParameterDirection.Input, New_Hostname);
            AddParam(cmd, "@New_OS", DbType.String, 100, 50, 0, ParameterDirection.Input, New_OS);
            AddParam(cmd, "@New_Status", DbType.Int32, 1, 1, 0, ParameterDirection.Input, New_Status);
            AddParam(cmd, "@xPrimaryKey", DbType.Int32, 8, 19, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            xPrimaryKey = get_long_value(((IDbDataParameter)cmd.Parameters["@xPrimaryKey"]).Value);
            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_DetailsInChangeRequest_SelectByChangeRequestID
    (
        long ChangeRequestID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_DetailsInChangeRequest_SelectByChangeRequestID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ChangeRequestID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ChangeRequestID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_DomainsInSite_DeleteByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_DomainsInSite_DeleteByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_DomainsInSite_Insert
    (
        long SiteID,
        string DomainName,
        int DomainStatus,
        ref int xPrimaryKey
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_DomainsInSite_Insert";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@SiteID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, SiteID);
            AddParam(cmd, "@DomainName", DbType.String, 200, 200, 0, ParameterDirection.Input, DomainName);
            AddParam(cmd, "@DomainStatus", DbType.Int32, 1, 1, 0, ParameterDirection.Input, DomainStatus);
            AddParam(cmd, "@xPrimaryKey", DbType.Int32, 4, 10, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            xPrimaryKey = get_int_value(((IDbDataParameter)cmd.Parameters["@xPrimaryKey"]).Value);
            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_DomainsInSite_SelectActiveBySiteID
    (
        long SiteID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_DomainsInSite_SelectActiveBySiteID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@SiteID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, SiteID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_DomainsInSite_SelectAll
    (
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_DomainsInSite_SelectAll";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_DomainsInSite_SelectByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_DomainsInSite_SelectByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void SP_DomainsInSite_SelectBySiteID
    (
        long SiteID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "SP_DomainsInSite_SelectBySiteID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@SiteID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, SiteID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_DomainsInSite_UpdateByID
    (
        long ID,
        long SiteID,
        string DomainName,
        int DomainStatus
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_DomainsInSite_UpdateByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@SiteID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, SiteID);
            AddParam(cmd, "@DomainName", DbType.String, 200, 200, 0, ParameterDirection.Input, DomainName);
            AddParam(cmd, "@DomainStatus", DbType.Int32, 1, 1, 0, ParameterDirection.Input, DomainStatus);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_GeneralStatus_SelectAll
    (
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_GeneralStatus_SelectAll";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_GroupMember_DeleteByID
    (
        long GroupID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_GroupMember_DeleteByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@GroupID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, GroupID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_GroupMember_Insert
    (
        string GroupName,
        long CreatedBy,
        int GroupStatus,
        ref long xPrimaryKey
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_GroupMember_Insert";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@GroupName", DbType.String, 100, 50, 0, ParameterDirection.Input, GroupName);
            AddParam(cmd, "@CreatedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, CreatedBy);
            AddParam(cmd, "@GroupStatus", DbType.Int32, 1, 1, 0, ParameterDirection.Input, GroupStatus);
            AddParam(cmd, "@xPrimaryKey", DbType.Int32, 8, 19, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            xPrimaryKey = get_long_value(((IDbDataParameter)cmd.Parameters["@xPrimaryKey"]).Value);
            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_GroupMember_SelectAll
    (
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_GroupMember_SelectAll";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_GroupMember_SelectByID
    (
        long GroupID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_GroupMember_SelectByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@GroupID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, GroupID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_GroupMember_UpdateByID
    (
        long GroupID,
        string GroupName,
        int GroupStatus,
        long ModifiedBy
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_GroupMember_UpdateByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@GroupID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, GroupID);
            AddParam(cmd, "@GroupName", DbType.String, 100, 50, 0, ParameterDirection.Input, GroupName);
            AddParam(cmd, "@GroupStatus", DbType.Int32, 1, 1, 0, ParameterDirection.Input, GroupStatus);
            AddParam(cmd, "@ModifiedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ModifiedBy);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_GroupMemberInResourcePermission_DeleteByID
    (
        long GroupMemberID,
        long ResourceID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_GroupMemberInResourcePermission_DeleteByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@GroupMemberID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, GroupMemberID);
            AddParam(cmd, "@ResourceID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ResourceID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_GroupMemberInResourcePermission_GetByID
    (
        long GroupMemberID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_GroupMemberInResourcePermission_GetByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@GroupMemberID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, GroupMemberID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_GroupMemberInResourcePermission_Insert
    (
        long GroupMemberID,
        long ResourceID,
        int Create0,
        int Read0,
        int Update0,
        int Delete0,
        int Status,
        long CreatedBy,
        ref long xPrimaryKey
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_GroupMemberInResourcePermission_Insert";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@GroupMemberID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, GroupMemberID);
            AddParam(cmd, "@ResourceID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ResourceID);
            AddParam(cmd, "@Create0", DbType.Int32, 1, 1, 0, ParameterDirection.Input, Create0);
            AddParam(cmd, "@Read0", DbType.Int32, 1, 1, 0, ParameterDirection.Input, Read0);
            AddParam(cmd, "@Update0", DbType.Int32, 1, 1, 0, ParameterDirection.Input, Update0);
            AddParam(cmd, "@Delete0", DbType.Int32, 1, 1, 0, ParameterDirection.Input, Delete0);
            AddParam(cmd, "@Status", DbType.Int32, 1, 1, 0, ParameterDirection.Input, Status);
            AddParam(cmd, "@CreatedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, CreatedBy);
            AddParam(cmd, "@xPrimaryKey", DbType.Int32, 8, 19, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            xPrimaryKey = get_long_value(((IDbDataParameter)cmd.Parameters["@xPrimaryKey"]).Value);
            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_GroupMemberInResourcePermission_SelectAll
    (
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_GroupMemberInResourcePermission_SelectAll";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_GroupMemberInResourcePermission_SelectByID
    (
        long GroupMemberID,
        long ResourceID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_GroupMemberInResourcePermission_SelectByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@GroupMemberID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, GroupMemberID);
            AddParam(cmd, "@ResourceID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ResourceID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void sp_GroupMemberInResourcePermission_UpdateByID
    (
        long GroupMemberID,
        long ResourceID,
        int Create0,
        int Read0,
        int Update0,
        int Delete0,
        int Status,
        long ModifiedBy,
        long xGroupMemberID,
        long xResourceID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "sp_GroupMemberInResourcePermission_UpdateByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@GroupMemberID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, GroupMemberID);
            AddParam(cmd, "@ResourceID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ResourceID);
            AddParam(cmd, "@Create0", DbType.Int32, 1, 1, 0, ParameterDirection.Input, Create0);
            AddParam(cmd, "@Read0", DbType.Int32, 1, 1, 0, ParameterDirection.Input, Read0);
            AddParam(cmd, "@Update0", DbType.Int32, 1, 1, 0, ParameterDirection.Input, Update0);
            AddParam(cmd, "@Delete0", DbType.Int32, 1, 1, 0, ParameterDirection.Input, Delete0);
            AddParam(cmd, "@Status", DbType.Int32, 1, 1, 0, ParameterDirection.Input, Status);
            AddParam(cmd, "@ModifiedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ModifiedBy);
            AddParam(cmd, "@xGroupMemberID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, xGroupMemberID);
            AddParam(cmd, "@xResourceID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, xResourceID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_HistoricalSRDetails_SelectByParentID
    (
        string ParentID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_HistoricalSRDetails_SelectByParentID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ParentID", DbType.String, 64, 32, 0, ParameterDirection.Input, ParentID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_HistoricalSRHeader_SelectByParentID
    (
        string ParentID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_HistoricalSRHeader_SelectByParentID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ParentID", DbType.String, 64, 32, 0, ParameterDirection.Input, ParentID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_HistoricalSRHeader_SelectBySiteID
    (
        int SiteID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_HistoricalSRHeader_SelectBySiteID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@SiteID", DbType.Int32, 4, 10, 0, ParameterDirection.Input, SiteID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_import
    (
        string S_No,
        string organisation_id,
        string organisation_fullname,
        string SiteID,
        string Costcentre,
        string User_Name,
        string Service_Type,
        string Monthly_OneTime,
        string Subscription_Start_Date,
        string Subscription_End_Date,
        string New_Existing_Terminated,
        string AssetID,
        string Hostname,
        string Remarks,
        ref int result,
        ref string errormsg
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_import";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@S_No", DbType.String, 200, 100, 0, ParameterDirection.Input, S_No);
            AddParam(cmd, "@organisation_id", DbType.String, 200, 100, 0, ParameterDirection.Input, organisation_id);
            AddParam(cmd, "@organisation_fullname", DbType.String, 200, 100, 0, ParameterDirection.Input, organisation_fullname);
            AddParam(cmd, "@SiteID", DbType.String, 200, 100, 0, ParameterDirection.Input, SiteID);
            AddParam(cmd, "@Costcentre", DbType.String, 200, 100, 0, ParameterDirection.Input, Costcentre);
            AddParam(cmd, "@User_Name", DbType.String, 200, 100, 0, ParameterDirection.Input, User_Name);
            AddParam(cmd, "@Service_Type", DbType.String, 200, 100, 0, ParameterDirection.Input, Service_Type);
            AddParam(cmd, "@Monthly_OneTime", DbType.String, 200, 100, 0, ParameterDirection.Input, Monthly_OneTime);
            AddParam(cmd, "@Subscription_Start_Date", DbType.String, 200, 100, 0, ParameterDirection.Input, Subscription_Start_Date);
            AddParam(cmd, "@Subscription_End_Date", DbType.String, 200, 100, 0, ParameterDirection.Input, Subscription_End_Date);
            AddParam(cmd, "@New_Existing_Terminated", DbType.String, 200, 100, 0, ParameterDirection.Input, New_Existing_Terminated);
            AddParam(cmd, "@AssetID", DbType.String, 200, 100, 0, ParameterDirection.Input, AssetID);
            AddParam(cmd, "@Hostname", DbType.String, 200, 100, 0, ParameterDirection.Input, Hostname);
            AddParam(cmd, "@Remarks", DbType.String, 200, 100, 0, ParameterDirection.Input, Remarks);
            AddParam(cmd, "@result", DbType.Int32, 4, 10, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@errormsg", DbType.String, 200, 200, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            result = get_int_value(((IDbDataParameter)cmd.Parameters["@result"]).Value);
            errormsg = get_string_value(((IDbDataParameter)cmd.Parameters["@errormsg"]).Value);
            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_IsRecordExists
    (
        string tablename,
        string fieldname,
        string value
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_IsRecordExists";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@tablename", DbType.String, 100, 50, 0, ParameterDirection.Input, tablename);
            AddParam(cmd, "@fieldname", DbType.String, 100, 50, 0, ParameterDirection.Input, fieldname);
            AddParam(cmd, "@value", DbType.String, 300, 150, 0, ParameterDirection.Input, value);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_KeyManagersInServiceForm_DeleteByID
    (
        long UserId
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_KeyManagersInServiceForm_DeleteByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@UserId", DbType.Int32, 8, 19, 0, ParameterDirection.Input, UserId);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_KeyManagersInServiceForm_GetByID
    (
        long UserId
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_KeyManagersInServiceForm_GetByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@UserId", DbType.Int32, 8, 19, 0, ParameterDirection.Input, UserId);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_KeyManagersInServiceForm_Insert
    (
        long ServiceFormID,
        ref long xPrimaryKey
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_KeyManagersInServiceForm_Insert";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ServiceFormID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ServiceFormID);
            AddParam(cmd, "@xPrimaryKey", DbType.Int32, 8, 19, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            xPrimaryKey = get_long_value(((IDbDataParameter)cmd.Parameters["@xPrimaryKey"]).Value);
            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_KeyManagersInServiceForm_SelectAll
    (
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_KeyManagersInServiceForm_SelectAll";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_KeyManagersInServiceForm_SelectByID
    (
        long UserId
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_KeyManagersInServiceForm_SelectByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@UserId", DbType.Int32, 8, 19, 0, ParameterDirection.Input, UserId);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_KeyManagersInServiceForm_UpdateByID
    (
        long UserId,
        long ServiceFormID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_KeyManagersInServiceForm_UpdateByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@UserId", DbType.Int32, 8, 19, 0, ParameterDirection.Input, UserId);
            AddParam(cmd, "@ServiceFormID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ServiceFormID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_MasterProfile_DeleteByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_MasterProfile_DeleteByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_MasterProfile_Insert
    (
        long CreatedBy,
        ref long xPrimaryKey
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_MasterProfile_Insert";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@CreatedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, CreatedBy);
            AddParam(cmd, "@xPrimaryKey", DbType.Int32, 8, 19, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            xPrimaryKey = get_long_value(((IDbDataParameter)cmd.Parameters["@xPrimaryKey"]).Value);
            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_MasterProfile_SelectByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_MasterProfile_SelectByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_MasterProfile_UpdateByID
    (
        long ID,
        long ModifiedBy
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_MasterProfile_UpdateByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@ModifiedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ModifiedBy);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void SP_Notice_DeleteByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "SP_Notice_DeleteByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_Notice_Insert
    (
        string Subject,
        string Body0,
        DateTime PublishDate,
        DateTime ExpiredDate,
        long CreatedBy,
        ref long xPrimaryKey
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_Notice_Insert";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@Subject", DbType.String, 400, 200, 0, ParameterDirection.Input, Subject);
            AddParam(cmd, "@Body0", DbType.String, 16, 0, 0, ParameterDirection.Input, Body0);
            AddParam(cmd, "@PublishDate", DbType.DateTime, 8, 23, 3, ParameterDirection.Input, PublishDate);
            AddParam(cmd, "@ExpiredDate", DbType.DateTime, 8, 23, 3, ParameterDirection.Input, ExpiredDate);
            AddParam(cmd, "@CreatedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, CreatedBy);
            AddParam(cmd, "@xPrimaryKey", DbType.Int32, 8, 19, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            xPrimaryKey = get_long_value(((IDbDataParameter)cmd.Parameters["@xPrimaryKey"]).Value);
            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_Notice_SelectAll
    (
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_Notice_SelectAll";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_Notice_SelectByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_Notice_SelectByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_Notice_SelectByNoExpired
    (
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_Notice_SelectByNoExpired";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_Notice_UpdateByID
    (
        long ID,
        string Subject,
        string Body0,
        DateTime PublishDate,
        DateTime ExpiredDate,
        long ModifiedBy
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_Notice_UpdateByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@Subject", DbType.String, 200, 100, 0, ParameterDirection.Input, Subject);
            AddParam(cmd, "@Body0", DbType.String, 16, 0, 0, ParameterDirection.Input, Body0);
            AddParam(cmd, "@PublishDate", DbType.DateTime, 8, 23, 3, ParameterDirection.Input, PublishDate);
            AddParam(cmd, "@ExpiredDate", DbType.DateTime, 8, 23, 3, ParameterDirection.Input, ExpiredDate);
            AddParam(cmd, "@ModifiedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ModifiedBy);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_Organization_Delete
    (
        int ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_Organization_Delete";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 4, 10, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_Organization_DeleteByID
    (
        int ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_Organization_DeleteByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 4, 10, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_Organization_Insert
    (
        string OrgIDName,
        string OrgName,
        int IsMinistry,
        int OrgStatus,
        long CreatedBy,
        ref int xPrimaryKey
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_Organization_Insert";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@OrgIDName", DbType.String, 400, 200, 0, ParameterDirection.Input, OrgIDName);
            AddParam(cmd, "@OrgName", DbType.String, 400, 200, 0, ParameterDirection.Input, OrgName);
            AddParam(cmd, "@IsMinistry", DbType.Int32, 1, 1, 0, ParameterDirection.Input, IsMinistry);
            AddParam(cmd, "@OrgStatus", DbType.Int32, 1, 1, 0, ParameterDirection.Input, OrgStatus);
            AddParam(cmd, "@CreatedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, CreatedBy);
            AddParam(cmd, "@xPrimaryKey", DbType.Int32, 4, 10, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            xPrimaryKey = get_int_value(((IDbDataParameter)cmd.Parameters["@xPrimaryKey"]).Value);
            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void SP_Organization_SelectActiveByID_BasedOnMinistry
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "SP_Organization_SelectActiveByID_BasedOnMinistry";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_Organization_SelectAll
    (
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_Organization_SelectAll";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_Organization_SelectAllActive
    (
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_Organization_SelectAllActive";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_Organization_SelectByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_Organization_SelectByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void SP_Organization_SelectByID_BasedOnMinistry
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "SP_Organization_SelectByID_BasedOnMinistry";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_Organization_UpdateByID
    (
        long ID,
        string OrgIDName,
        string OrgName,
        int IsMinistry,
        int OrgStatus,
        long ModifiedBy
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_Organization_UpdateByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@OrgIDName", DbType.String, 400, 200, 0, ParameterDirection.Input, OrgIDName);
            AddParam(cmd, "@OrgName", DbType.String, 400, 200, 0, ParameterDirection.Input, OrgName);
            AddParam(cmd, "@IsMinistry", DbType.Int32, 1, 1, 0, ParameterDirection.Input, IsMinistry);
            AddParam(cmd, "@OrgStatus", DbType.Int32, 1, 1, 0, ParameterDirection.Input, OrgStatus);
            AddParam(cmd, "@ModifiedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ModifiedBy);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void SP_ReasonsInChangeRequest_DeleteByChangeRequestID
    (
        long ChangeRequestID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "SP_ReasonsInChangeRequest_DeleteByChangeRequestID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ChangeRequestID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ChangeRequestID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void SP_ReasonsInChangeRequest_Insert
    (
        long ChangeRequestID,
        long ChangeRequestReasonID,
        ref long xPrimaryKey
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "SP_ReasonsInChangeRequest_Insert";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ChangeRequestID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ChangeRequestID);
            AddParam(cmd, "@ChangeRequestReasonID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ChangeRequestReasonID);
            AddParam(cmd, "@xPrimaryKey", DbType.Int32, 8, 19, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            xPrimaryKey = get_long_value(((IDbDataParameter)cmd.Parameters["@xPrimaryKey"]).Value);
            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void sp_ReasonsInChangeRequest_SelectByChangeRequestID
    (
        long ChangeRequestID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "sp_ReasonsInChangeRequest_SelectByChangeRequestID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ChangeRequestID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ChangeRequestID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_ResourceMenu_DeleteByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_ResourceMenu_DeleteByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_ResourceMenu_GetByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_ResourceMenu_GetByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_ResourceMenu_Insert
    (
        long Parent,
        string ResourceName,
        string PageURL,
        int PageOrder,
        int Status,
        long CreatedBy,
        ref long xPrimaryKey
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_ResourceMenu_Insert";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@Parent", DbType.Int32, 8, 19, 0, ParameterDirection.Input, Parent);
            AddParam(cmd, "@ResourceName", DbType.String, 100, 50, 0, ParameterDirection.Input, ResourceName);
            AddParam(cmd, "@PageURL", DbType.String, 300, 150, 0, ParameterDirection.Input, PageURL);
            AddParam(cmd, "@PageOrder", DbType.Int32, 4, 10, 0, ParameterDirection.Input, PageOrder);
            AddParam(cmd, "@Status", DbType.Int32, 1, 1, 0, ParameterDirection.Input, Status);
            AddParam(cmd, "@CreatedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, CreatedBy);
            AddParam(cmd, "@xPrimaryKey", DbType.Int32, 8, 19, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            xPrimaryKey = get_long_value(((IDbDataParameter)cmd.Parameters["@xPrimaryKey"]).Value);
            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_ResourceMenu_SelectAll
    (
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_ResourceMenu_SelectAll";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_ResourceMenu_SelectByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_ResourceMenu_SelectByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_ResourceMenu_SelectByStructure
    (
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_ResourceMenu_SelectByStructure";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_ResourceMenu_SelectByStructureWithGroupMemberID
    (
        long GroupMemberID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_ResourceMenu_SelectByStructureWithGroupMemberID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@GroupMemberID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, GroupMemberID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_ResourceMenu_UpdateByID
    (
        long ID,
        long Parent,
        string ResourceName,
        string PageURL,
        int PageOrder,
        int Status,
        long ModifiedBy
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_ResourceMenu_UpdateByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@Parent", DbType.Int32, 8, 19, 0, ParameterDirection.Input, Parent);
            AddParam(cmd, "@ResourceName", DbType.String, 100, 50, 0, ParameterDirection.Input, ResourceName);
            AddParam(cmd, "@PageURL", DbType.String, 300, 150, 0, ParameterDirection.Input, PageURL);
            AddParam(cmd, "@PageOrder", DbType.Int32, 4, 10, 0, ParameterDirection.Input, PageOrder);
            AddParam(cmd, "@Status", DbType.Int32, 1, 1, 0, ParameterDirection.Input, Status);
            AddParam(cmd, "@ModifiedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ModifiedBy);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_Role_DeleteByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_Role_DeleteByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_Role_GetByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_Role_GetByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_Role_Insert
    (
        string RoleName,
        int Status,
        long CreatedBy,
        ref long xPrimaryKey
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_Role_Insert";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@RoleName", DbType.String, 100, 50, 0, ParameterDirection.Input, RoleName);
            AddParam(cmd, "@Status", DbType.Int32, 1, 1, 0, ParameterDirection.Input, Status);
            AddParam(cmd, "@CreatedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, CreatedBy);
            AddParam(cmd, "@xPrimaryKey", DbType.Int32, 8, 19, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            xPrimaryKey = get_long_value(((IDbDataParameter)cmd.Parameters["@xPrimaryKey"]).Value);
            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_Role_SelectAll
    (
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_Role_SelectAll";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_Role_SelectByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_Role_SelectByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_Role_UpdateByID
    (
        long ID,
        string RoleName,
        int Status,
        long ModifiedBy
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_Role_UpdateByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RoleName", DbType.String, 100, 50, 0, ParameterDirection.Input, RoleName);
            AddParam(cmd, "@Status", DbType.Int32, 1, 1, 0, ParameterDirection.Input, Status);
            AddParam(cmd, "@ModifiedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ModifiedBy);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_SelectSubmittedEffCostCentreTransferSR
    (
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_SelectSubmittedEffCostCentreTransferSR";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_SitesInOrganization_DeleteByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_SitesInOrganization_DeleteByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_SitesInOrganization_GetByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_SitesInOrganization_GetByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_SitesInOrganization_Insert
    (
        long OrgID,
        string SiteIDName,
        string SiteName,
        int SiteStatus,
        long CreatedBy,
        ref int xPrimaryKey
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_SitesInOrganization_Insert";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@OrgID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, OrgID);
            AddParam(cmd, "@SiteIDName", DbType.String, 400, 200, 0, ParameterDirection.Input, SiteIDName);
            AddParam(cmd, "@SiteName", DbType.String, 400, 200, 0, ParameterDirection.Input, SiteName);
            AddParam(cmd, "@SiteStatus", DbType.Int32, 1, 1, 0, ParameterDirection.Input, SiteStatus);
            AddParam(cmd, "@CreatedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, CreatedBy);
            AddParam(cmd, "@xPrimaryKey", DbType.Int32, 4, 10, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            xPrimaryKey = get_int_value(((IDbDataParameter)cmd.Parameters["@xPrimaryKey"]).Value);
            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_SitesInOrganization_SelectActiveByOrgID
    (
        long OrgID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_SitesInOrganization_SelectActiveByOrgID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@OrgID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, OrgID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_SitesInOrganization_SelectAll
    (
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_SitesInOrganization_SelectAll";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_SitesInOrganization_SelectByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_SitesInOrganization_SelectByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_SitesInOrganization_SelectByOrgID
    (
        long OrgID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_SitesInOrganization_SelectByOrgID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@OrgID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, OrgID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_SitesInOrganization_UpdateByID
    (
        long ID,
        long OrgID,
        string SiteIDName,
        string SiteName,
        int SiteStatus,
        long ModifiedBy
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_SitesInOrganization_UpdateByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@OrgID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, OrgID);
            AddParam(cmd, "@SiteIDName", DbType.String, 400, 200, 0, ParameterDirection.Input, SiteIDName);
            AddParam(cmd, "@SiteName", DbType.String, 400, 200, 0, ParameterDirection.Input, SiteName);
            AddParam(cmd, "@SiteStatus", DbType.Int32, 1, 1, 0, ParameterDirection.Input, SiteStatus);
            AddParam(cmd, "@ModifiedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ModifiedBy);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void SP_Subscriber_CheckCCStartDate
    (
        string AssetID,
        DateTime EffectiveDate
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "SP_Subscriber_CheckCCStartDate";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@AssetID", DbType.String, 100, 50, 0, ParameterDirection.Input, AssetID);
            AddParam(cmd, "@EffectiveDate", DbType.DateTime, 8, 23, 3, ParameterDirection.Input, EffectiveDate);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }

    public void SP_Subscriber_CheckStartDate_MultiProvisioning
    (
        string AssetID,
        DateTime EffectiveDate,
        DateTime TerminatedDate,
        long IgnoreSubscriberId
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "SP_Subscriber_CheckStartDate_MultiProvisioning";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@AssetID", DbType.String, 100, 50, 0, ParameterDirection.Input, AssetID);
            AddParam(cmd, "@EffectiveDate", DbType.DateTime, 8, 23, 3, ParameterDirection.Input, EffectiveDate);
            AddParam(cmd, "@TerminatedDate", DbType.DateTime, 8, 23, 3, ParameterDirection.Input, TerminatedDate);
            AddParam(cmd, "@IgnoreSubscriberId", DbType.Int32, 8, 19, 0, ParameterDirection.Input, IgnoreSubscriberId);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_Subscriber_DeleteByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_Subscriber_DeleteByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_Subscriber_GetByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_Subscriber_GetByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_Subscriber_Insert
    (
        long ServiceFormID,
        long MasterProfileID,
        long CreatedBy,
        int Status,
        DateTime EffectiveDate,
        ref long xPrimaryKey
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_Subscriber_Insert";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ServiceFormID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ServiceFormID);
            AddParam(cmd, "@MasterProfileID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, MasterProfileID);
            AddParam(cmd, "@CreatedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, CreatedBy);
            AddParam(cmd, "@Status", DbType.Int32, 1, 1, 0, ParameterDirection.Input, Status);
            AddParam(cmd, "@EffectiveDate", DbType.DateTime, 8, 23, 3, ParameterDirection.Input, EffectiveDate);
            AddParam(cmd, "@xPrimaryKey", DbType.Int32, 8, 19, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            xPrimaryKey = get_long_value(((IDbDataParameter)cmd.Parameters["@xPrimaryKey"]).Value);
            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_Subscriber_SelectAll
    (
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_Subscriber_SelectAll";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_Subscriber_SelectAllByCostCentre
    (
        long CostCentreID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_Subscriber_SelectAllByCostCentre";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@CostCentreID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, CostCentreID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_Subscriber_SelectAllByOrg
    (
        long OrgID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_Subscriber_SelectAllByOrg";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@OrgID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, OrgID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void SP_Subscriber_SelectByAssetID
    (
        string AssetID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "SP_Subscriber_SelectByAssetID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@AssetID", DbType.String, 100, 50, 0, ParameterDirection.Input, AssetID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_Subscriber_SelectByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_Subscriber_SelectByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_Subscriber_SelectBySiteID
    (
        long SiteID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_Subscriber_SelectBySiteID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@SiteID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, SiteID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_Subscriber_UpdateByID
    (
        long ID,
        long MasterProfileID,
        long ModifiedBy,
        int Status,
        string NRICName,
        string Email
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_Subscriber_UpdateByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@MasterProfileID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, MasterProfileID);
            AddParam(cmd, "@ModifiedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ModifiedBy);
            AddParam(cmd, "@Status", DbType.Int32, 1, 1, 0, ParameterDirection.Input, Status);
            AddParam(cmd, "@NRICName", DbType.String, 200, 200, 0, ParameterDirection.Input, NRICName);
            AddParam(cmd, "@Email", DbType.String, 200, 200, 0, ParameterDirection.Input, Email);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_Subscriber_UpdateByTermination
    (
        long ID,
        DateTime TerminatedDate,
        long TerminatedBy,
        int Status
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_Subscriber_UpdateByTermination";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@TerminatedDate", DbType.DateTime, 8, 23, 3, ParameterDirection.Input, TerminatedDate);
            AddParam(cmd, "@TerminatedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, TerminatedBy);
            AddParam(cmd, "@Status", DbType.Int32, 1, 1, 0, ParameterDirection.Input, Status);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_Template_DeleteByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_Template_DeleteByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_Template_Insert
    (
        long TemplateType,
        string TemplateName,
        string EmailTo,
        string EmailCc,
        string EmailBcc,
        int IsEmailToDestKM,
        string Subject0,
        int IsAttachTabFile,
        int IsAttachKMTextFile,
        string Body0,
        string Footer0,
        int IsDetailStatusChange,
        int TemplateStatus,
        long CreatedBy,
        ref long xPrimaryKey
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_Template_Insert";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@TemplateType", DbType.Int32, 8, 19, 0, ParameterDirection.Input, TemplateType);
            AddParam(cmd, "@TemplateName", DbType.String, 200, 100, 0, ParameterDirection.Input, TemplateName);
            AddParam(cmd, "@EmailTo", DbType.String, 510, 255, 0, ParameterDirection.Input, EmailTo);
            AddParam(cmd, "@EmailCc", DbType.String, 510, 255, 0, ParameterDirection.Input, EmailCc);
            AddParam(cmd, "@EmailBcc", DbType.String, 1020, 510, 0, ParameterDirection.Input, EmailBcc);
            AddParam(cmd, "@IsEmailToDestKM", DbType.Int32, 1, 1, 0, ParameterDirection.Input, IsEmailToDestKM);
            AddParam(cmd, "@Subject0", DbType.String, 510, 255, 0, ParameterDirection.Input, Subject0);
            AddParam(cmd, "@IsAttachTabFile", DbType.Int32, 1, 1, 0, ParameterDirection.Input, IsAttachTabFile);
            AddParam(cmd, "@IsAttachKMTextFile", DbType.Int32, 1, 1, 0, ParameterDirection.Input, IsAttachKMTextFile);
            AddParam(cmd, "@Body0", DbType.String, 16, 0, 0, ParameterDirection.Input, Body0);
            AddParam(cmd, "@Footer0", DbType.String, 16, 0, 0, ParameterDirection.Input, Footer0);
            AddParam(cmd, "@IsDetailStatusChange", DbType.Int32, 1, 1, 0, ParameterDirection.Input, IsDetailStatusChange);
            AddParam(cmd, "@TemplateStatus", DbType.Int32, 1, 1, 0, ParameterDirection.Input, TemplateStatus);
            AddParam(cmd, "@CreatedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, CreatedBy);
            AddParam(cmd, "@xPrimaryKey", DbType.Int32, 8, 19, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            xPrimaryKey = get_long_value(((IDbDataParameter)cmd.Parameters["@xPrimaryKey"]).Value);
            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_Template_SelectActiveByTemplateType
    (
        long TemplateType,
        int IsDetailStatusChange,
        long RequestStatus,
        long RequestType
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_Template_SelectActiveByTemplateType";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@TemplateType", DbType.Int32, 8, 19, 0, ParameterDirection.Input, TemplateType);
            AddParam(cmd, "@IsDetailStatusChange", DbType.Int32, 1, 1, 0, ParameterDirection.Input, IsDetailStatusChange);
            AddParam(cmd, "@RequestStatus", DbType.Int32, 8, 19, 0, ParameterDirection.Input, RequestStatus);
            AddParam(cmd, "@RequestType", DbType.Int32, 8, 19, 0, ParameterDirection.Input, RequestType);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_Template_SelectAll
    (
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_Template_SelectAll";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_Template_SelectByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_Template_SelectByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_Template_UpdateByID
    (
        long ID,
        long TemplateType,
        string TemplateName,
        string EmailTo,
        string EmailCc,
        string EmailBcc,
        int IsEmailToDestKM,
        string Subject0,
        int IsAttachTabFile,
        int IsAttachKMTextFile,
        string Body0,
        string Footer0,
        int IsDetailStatusChange,
        int TemplateStatus,
        long ModifiedBy
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_Template_UpdateByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@TemplateType", DbType.Int32, 8, 19, 0, ParameterDirection.Input, TemplateType);
            AddParam(cmd, "@TemplateName", DbType.String, 200, 100, 0, ParameterDirection.Input, TemplateName);
            AddParam(cmd, "@EmailTo", DbType.String, 510, 255, 0, ParameterDirection.Input, EmailTo);
            AddParam(cmd, "@EmailCc", DbType.String, 510, 255, 0, ParameterDirection.Input, EmailCc);
            AddParam(cmd, "@EmailBcc", DbType.String, 1020, 510, 0, ParameterDirection.Input, EmailBcc);
            AddParam(cmd, "@IsEmailToDestKM", DbType.Int32, 1, 1, 0, ParameterDirection.Input, IsEmailToDestKM);
            AddParam(cmd, "@Subject0", DbType.String, 510, 255, 0, ParameterDirection.Input, Subject0);
            AddParam(cmd, "@IsAttachTabFile", DbType.Int32, 1, 1, 0, ParameterDirection.Input, IsAttachTabFile);
            AddParam(cmd, "@IsAttachKMTextFile", DbType.Int32, 1, 1, 0, ParameterDirection.Input, IsAttachKMTextFile);
            AddParam(cmd, "@Body0", DbType.String, 16, 0, 0, ParameterDirection.Input, Body0);
            AddParam(cmd, "@Footer0", DbType.String, 16, 0, 0, ParameterDirection.Input, Footer0);
            AddParam(cmd, "@IsDetailStatusChange", DbType.Int32, 1, 1, 0, ParameterDirection.Input, IsDetailStatusChange);
            AddParam(cmd, "@TemplateStatus", DbType.Int32, 1, 1, 0, ParameterDirection.Input, TemplateStatus);
            AddParam(cmd, "@ModifiedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ModifiedBy);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_TemplateBodyDetails_DeleteByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_TemplateBodyDetails_DeleteByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_TemplateBodyDetails_DeleteByTemplateID
    (
        long TemplateID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_TemplateBodyDetails_DeleteByTemplateID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@TemplateID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, TemplateID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_TemplateBodyDetails_Insert
    (
        long TemplateID,
        string ColumnName,
        ref long xPrimaryKey
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_TemplateBodyDetails_Insert";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@TemplateID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, TemplateID);
            AddParam(cmd, "@ColumnName", DbType.String, 200, 100, 0, ParameterDirection.Input, ColumnName);
            AddParam(cmd, "@xPrimaryKey", DbType.Int32, 8, 19, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            xPrimaryKey = get_long_value(((IDbDataParameter)cmd.Parameters["@xPrimaryKey"]).Value);
            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_TemplateBodyDetails_SelectByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_TemplateBodyDetails_SelectByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_TemplateBodyDetails_SelectByTemplateID
    (
        long TemplateID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_TemplateBodyDetails_SelectByTemplateID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@TemplateID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, TemplateID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_TemplateBodyDetails_UpdateByID
    (
        long ID,
        long TemplateID,
        string ColumnName
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_TemplateBodyDetails_UpdateByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@TemplateID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, TemplateID);
            AddParam(cmd, "@ColumnName", DbType.String, 200, 100, 0, ParameterDirection.Input, ColumnName);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_TemplateColumnMapping_SelectByTemplateType
    (
        long TemplateType
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_TemplateColumnMapping_SelectByTemplateType";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@TemplateType", DbType.Int32, 8, 19, 0, ParameterDirection.Input, TemplateType);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_TemplateRecipientGroup_DeleteByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_TemplateRecipientGroup_DeleteByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_TemplateRecipientGroup_DeleteByTemplateID
    (
        long TemplateID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_TemplateRecipientGroup_DeleteByTemplateID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@TemplateID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, TemplateID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_TemplateRecipientGroup_Insert
    (
        long TemplateID,
        string SendToType,
        long GroupMemberID,
        ref long xPrimaryKey
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_TemplateRecipientGroup_Insert";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@TemplateID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, TemplateID);
            AddParam(cmd, "@SendToType", DbType.String, 10, 5, 0, ParameterDirection.Input, SendToType);
            AddParam(cmd, "@GroupMemberID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, GroupMemberID);
            AddParam(cmd, "@xPrimaryKey", DbType.Int32, 8, 19, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            xPrimaryKey = get_long_value(((IDbDataParameter)cmd.Parameters["@xPrimaryKey"]).Value);
            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_TemplateRecipientGroup_SelectByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_TemplateRecipientGroup_SelectByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_TemplateRecipientGroup_SelectByTemplateIDSendToType
    (
        long TemplateID,
        string SendToType
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_TemplateRecipientGroup_SelectByTemplateIDSendToType";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@TemplateID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, TemplateID);
            AddParam(cmd, "@SendToType", DbType.String, 10, 5, 0, ParameterDirection.Input, SendToType);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_TemplateRecipientGroup_UpdateByID
    (
        long ID,
        long TemplateID,
        string SendToType,
        long GroupMemberID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_TemplateRecipientGroup_UpdateByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@TemplateID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, TemplateID);
            AddParam(cmd, "@SendToType", DbType.String, 10, 5, 0, ParameterDirection.Input, SendToType);
            AddParam(cmd, "@GroupMemberID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, GroupMemberID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_TemplateRequestStatus_DeleteByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_TemplateRequestStatus_DeleteByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_TemplateRequestStatus_DeleteByTemplateID
    (
        long TemplateID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_TemplateRequestStatus_DeleteByTemplateID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@TemplateID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, TemplateID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_TemplateRequestStatus_Insert
    (
        long TemplateID,
        long RequestStatus,
        ref long xPrimaryKey
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_TemplateRequestStatus_Insert";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@TemplateID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, TemplateID);
            AddParam(cmd, "@RequestStatus", DbType.Int32, 8, 19, 0, ParameterDirection.Input, RequestStatus);
            AddParam(cmd, "@xPrimaryKey", DbType.Int32, 8, 19, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            xPrimaryKey = get_long_value(((IDbDataParameter)cmd.Parameters["@xPrimaryKey"]).Value);
            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_TemplateRequestStatus_SelectByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_TemplateRequestStatus_SelectByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_TemplateRequestStatus_SelectByTemplateID
    (
        long TemplateID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_TemplateRequestStatus_SelectByTemplateID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@TemplateID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, TemplateID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_TemplateRequestStatus_UpdateByID
    (
        long ID,
        long TemplateID,
        long RequestStatus
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_TemplateRequestStatus_UpdateByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@TemplateID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, TemplateID);
            AddParam(cmd, "@RequestStatus", DbType.Int32, 8, 19, 0, ParameterDirection.Input, RequestStatus);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_TemplateRequestType_DeleteByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_TemplateRequestType_DeleteByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_TemplateRequestType_DeleteByTemplateID
    (
        long TemplateID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_TemplateRequestType_DeleteByTemplateID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@TemplateID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, TemplateID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_TemplateRequestType_Insert
    (
        long TemplateID,
        long RequestType,
        ref long xPrimaryKey
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_TemplateRequestType_Insert";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@TemplateID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, TemplateID);
            AddParam(cmd, "@RequestType", DbType.Int32, 8, 19, 0, ParameterDirection.Input, RequestType);
            AddParam(cmd, "@xPrimaryKey", DbType.Int32, 8, 19, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            xPrimaryKey = get_long_value(((IDbDataParameter)cmd.Parameters["@xPrimaryKey"]).Value);
            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_TemplateRequestType_SelectByID
    (
        long ID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_TemplateRequestType_SelectByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_TemplateRequestType_SelectByTemplateID
    (
        long TemplateID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_TemplateRequestType_SelectByTemplateID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@TemplateID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, TemplateID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_TemplateRequestType_UpdateByID
    (
        long ID,
        long TemplateID,
        long RequestType
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_TemplateRequestType_UpdateByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@ID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ID);
            AddParam(cmd, "@TemplateID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, TemplateID);
            AddParam(cmd, "@RequestType", DbType.Int32, 8, 19, 0, ParameterDirection.Input, RequestType);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_UserProfile_DeleteByID
    (
        long UserID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_UserProfile_DeleteByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@UserID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, UserID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_UserProfile_DoLogin
    (
        string LoginID,
        string LoginPassword
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_UserProfile_DoLogin";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@LoginID", DbType.String, 400, 200, 0, ParameterDirection.Input, LoginID);
            AddParam(cmd, "@LoginPassword", DbType.String, 400, 200, 0, ParameterDirection.Input, LoginPassword);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_UserProfile_GetByID
    (
        long UserID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_UserProfile_GetByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@UserID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, UserID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_UserProfile_Insert
    (
        string LoginId,
        string LoginPassword,
        string NRIC,
        string Name0,
        string Address01,
        string Address02,
        string PostCode,
        string PrimaryPhone,
        string SecondaryPhone,
        string FaxNumber,
        string Email,
        long UserTypeID,
        long OrgID,
        long SiteID,
        long CostCentreID,
        int UserStatus,
        long CreatedBy,
        ref int xPrimaryKey
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_UserProfile_Insert";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@LoginId", DbType.String, 400, 200, 0, ParameterDirection.Input, LoginId);
            AddParam(cmd, "@LoginPassword", DbType.String, 200, 200, 0, ParameterDirection.Input, LoginPassword);
            AddParam(cmd, "@NRIC", DbType.String, 200, 200, 0, ParameterDirection.Input, NRIC);
            AddParam(cmd, "@Name0", DbType.String, 400, 200, 0, ParameterDirection.Input, Name0);
            AddParam(cmd, "@Address01", DbType.String, 400, 200, 0, ParameterDirection.Input, Address01);
            AddParam(cmd, "@Address02", DbType.String, 400, 200, 0, ParameterDirection.Input, Address02);
            AddParam(cmd, "@PostCode", DbType.String, 10, 10, 0, ParameterDirection.Input, PostCode);
            AddParam(cmd, "@PrimaryPhone", DbType.String, 15, 15, 0, ParameterDirection.Input, PrimaryPhone);
            AddParam(cmd, "@SecondaryPhone", DbType.String, 15, 15, 0, ParameterDirection.Input, SecondaryPhone);
            AddParam(cmd, "@FaxNumber", DbType.String, 15, 15, 0, ParameterDirection.Input, FaxNumber);
            AddParam(cmd, "@Email", DbType.String, 200, 200, 0, ParameterDirection.Input, Email);
            AddParam(cmd, "@UserTypeID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, UserTypeID);
            AddParam(cmd, "@OrgID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, OrgID);
            AddParam(cmd, "@SiteID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, SiteID);
            AddParam(cmd, "@CostCentreID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, CostCentreID);
            AddParam(cmd, "@UserStatus", DbType.Int32, 1, 1, 0, ParameterDirection.Input, UserStatus);
            AddParam(cmd, "@CreatedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, CreatedBy);
            AddParam(cmd, "@xPrimaryKey", DbType.Int32, 4, 10, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            xPrimaryKey = get_int_value(((IDbDataParameter)cmd.Parameters["@xPrimaryKey"]).Value);
            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_UserProfile_SelectActiveByGroupIDSiteID
    (
        long GroupID,
        long SiteID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_UserProfile_SelectActiveByGroupIDSiteID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@GroupID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, GroupID);
            AddParam(cmd, "@SiteID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, SiteID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_UserProfile_SelectActiveKM
    (
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_UserProfile_SelectActiveKM";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_UserProfile_SelectAll
    (
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_UserProfile_SelectAll";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_UserProfile_SelectAllKM
    (
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_UserProfile_SelectAllKM";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_UserProfile_SelectAllKMBySiteID
    (
        long SiteID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_UserProfile_SelectAllKMBySiteID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@SiteID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, SiteID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_UserProfile_SelectBookingAdmin
    (
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_UserProfile_SelectBookingAdmin";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_UserProfile_SelectByEmail
    (
        string Email
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_UserProfile_SelectByEmail";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@Email", DbType.String, 200, 200, 0, ParameterDirection.Input, Email);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_UserProfile_SelectByID
    (
        long UserID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_UserProfile_SelectByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@UserID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, UserID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_UserProfile_SelectByLoginID
    (
        string LoginID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_UserProfile_SelectByLoginID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@LoginID", DbType.String, 400, 200, 0, ParameterDirection.Input, LoginID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_UserProfile_UpdateByID
    (
        long UserID,
        string LoginId,
        string LoginPassword,
        string NRIC,
        string Name0,
        string Address01,
        string Address02,
        string PostCode,
        string PrimaryPhone,
        string SecondaryPhone,
        string FaxNumber,
        string Email,
        long UserTypeID,
        long OrgID,
        long SiteID,
        long CostCentreID,
        int UserStatus,
        long ModifiedBy
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_UserProfile_UpdateByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@UserID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, UserID);
            AddParam(cmd, "@LoginId", DbType.String, 400, 200, 0, ParameterDirection.Input, LoginId);
            AddParam(cmd, "@LoginPassword", DbType.String, 200, 200, 0, ParameterDirection.Input, LoginPassword);
            AddParam(cmd, "@NRIC", DbType.String, 200, 200, 0, ParameterDirection.Input, NRIC);
            AddParam(cmd, "@Name0", DbType.String, 400, 200, 0, ParameterDirection.Input, Name0);
            AddParam(cmd, "@Address01", DbType.String, 400, 200, 0, ParameterDirection.Input, Address01);
            AddParam(cmd, "@Address02", DbType.String, 400, 200, 0, ParameterDirection.Input, Address02);
            AddParam(cmd, "@PostCode", DbType.String, 10, 10, 0, ParameterDirection.Input, PostCode);
            AddParam(cmd, "@PrimaryPhone", DbType.String, 15, 15, 0, ParameterDirection.Input, PrimaryPhone);
            AddParam(cmd, "@SecondaryPhone", DbType.String, 15, 15, 0, ParameterDirection.Input, SecondaryPhone);
            AddParam(cmd, "@FaxNumber", DbType.String, 15, 15, 0, ParameterDirection.Input, FaxNumber);
            AddParam(cmd, "@Email", DbType.String, 200, 200, 0, ParameterDirection.Input, Email);
            AddParam(cmd, "@UserTypeID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, UserTypeID);
            AddParam(cmd, "@OrgID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, OrgID);
            AddParam(cmd, "@SiteID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, SiteID);
            AddParam(cmd, "@CostCentreID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, CostCentreID);
            AddParam(cmd, "@UserStatus", DbType.Int32, 1, 1, 0, ParameterDirection.Input, UserStatus);
            AddParam(cmd, "@ModifiedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ModifiedBy);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_UserProfile_UpdateByLoginIDForPassword
    (
        string LoginID,
        string LoginPassword
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_UserProfile_UpdateByLoginIDForPassword";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@LoginID", DbType.String, 400, 200, 0, ParameterDirection.Input, LoginID);
            AddParam(cmd, "@LoginPassword", DbType.String, 400, 200, 0, ParameterDirection.Input, LoginPassword);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_UserProfile_UpdateUserStatusByUserID
    (
        long UserID,
        int UserStatus,
        long ModifiedBy
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_UserProfile_UpdateUserStatusByUserID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@UserID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, UserID);
            AddParam(cmd, "@UserStatus", DbType.Int32, 1, 1, 0, ParameterDirection.Input, UserStatus);
            AddParam(cmd, "@ModifiedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ModifiedBy);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_UsersInRole_DeleteByID
    (
        long UserID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_UsersInRole_DeleteByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@UserID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, UserID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_UsersInRole_GetByID
    (
        long UserID,
        long RoleID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_UsersInRole_GetByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@UserID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, UserID);
            AddParam(cmd, "@RoleID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, RoleID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_UsersInRole_Insert
    (
        long RoleID,
        long UserID,
        long CreatedBy,
        ref long xPrimaryKey
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_UsersInRole_Insert";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@RoleID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, RoleID);
            AddParam(cmd, "@UserID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, UserID);
            AddParam(cmd, "@CreatedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, CreatedBy);
            AddParam(cmd, "@xPrimaryKey", DbType.Int32, 8, 19, 0, ParameterDirection.Output, null);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            xPrimaryKey = get_long_value(((IDbDataParameter)cmd.Parameters["@xPrimaryKey"]).Value);
            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_UsersInRole_SelectAll
    (
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_UsersInRole_SelectAll";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_UsersInRole_SelectByID
    (
        long UserID,
        long RoleID
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_UsersInRole_SelectByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@UserID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, UserID);
            AddParam(cmd, "@RoleID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, RoleID);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
    public void Sp_UsersInRole_UpdateByID
    (
        long UserID,
        long RoleID,
        long ModifiedBy
    )
    {
        IDbConnection conn = null;
        IDbTransaction tran = null;
        IDbCommand cmd = null;
        try
        {
            conn = this.GetConnection();
            tran = this.GetTransaction();
            cmd = this.CreateDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Sp_UsersInRole_UpdateByID";
            cmd.CommandTimeout = this.ExecuteTimeout;
            cmd.CommandType = CommandType.StoredProcedure;
            if (tran != null) cmd.Transaction = tran;

            AddParam(cmd, "@UserID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, UserID);
            AddParam(cmd, "@RoleID", DbType.Int32, 8, 19, 0, ParameterDirection.Input, RoleID);
            AddParam(cmd, "@ModifiedBy", DbType.Int32, 8, 19, 0, ParameterDirection.Input, ModifiedBy);
            AddParam(cmd, "@RETURN_VALUE", DbType.Int32, 4, 4, 0, ParameterDirection.ReturnValue, null);
            cmd.ExecuteNonQuery();

            int _temp = Convert.ToInt32(((IDbDataParameter)cmd.Parameters["@RETURN_VALUE"]).Value.ToString());
        }
        finally
        {
            if (cmd != null) cmd.Dispose();
            if (conn != null && !this.InTransaction)
            {
                conn.Close();
                conn.Dispose();
            }
        }
    }
}
//}